第三章 “Hello World”
3.1 构建和安装 zlog
1. 下载 zlog:
链接: [https://github.com/HardySimpson/zlog/archive/latest-stable.tar.gz]
2. 解压并进入目录:
$ tar -zxvf zlog-latest-stable.tar.gz
$ cd zlog-latest-stable/
3. 编译并安装:
$ make
$ sudo make install
或者安装到指定目录:
$ sudo make PREFIX=/usr/local/ install
4. 配置系统设置:
$ sudo vi /etc/ld.so.conf
/usr/local/lib
$ sudo ldconfig
5. 其他可用的 make 命令:
make 32bit
:在64位机器上编译32位版本,需要libc6-dev-i386
make noopt
:无 GCC 优化make doc
:需要lyx
和hevea
make test
:测试代码,也是 zlog 的好例子
3.2 在用户应用程序中调用和链接 zlog
1. 包含头文件:
#include "zlog.h"
2. 编译和链接:
$ cc -c -o app.o app.c -I/usr/local/include
$ cc -o app app.o -L/usr/local/lib -lzlog -lpthread
3.3 Hello World 示例
1. 创建