zookeeper C API 的安装和使用指南

来源:互联网 发布:java读取usb接口 编辑:程序博客网 时间:2024/05/31 19:43

1
下载 zookeeper-3.3.6.zip
编译 /zookeeper-3.3.6/src/c
./configure --prefix=/hfx/zookeeper 
make
make install

--prefix 类似这种参数有多中,./configure --help

编译好后可以看到如下路径:

[hfx@74 ~]$ cd zookeeper/
[hfx@74 zookeeper]$ ll
total 24
drwxrwxr-x  2 hfx hfx 4096 Mar 11 16:43 bin
drwxrwxr-x  3 hfx hfx 4096 Mar 11 16:43 include
drwxrwxr-x  2 hfx hfx 4096 Mar 11 16:43 lib
说明编译成功

2
使用:在cmake文件里加上编译好的lib文件路径,如果你需要编译多线程版本客户端程序,请添加编译选项 -DTHREADED,同时链接时应链接 zookeeper_mt 库;如果你需要编译单线程客户端程序,请不要添加编译选项 -DTHREADED,同时链接时应链接 zookeeper_st 库。
 INCLUDE_DIRECTORIES(
 ./
 /usr/local/include
 /home/hfx/zookeeper/include/c-client-src
 )
 
 LINK_DIRECTORIES(
 /usr/local/lib
 /home/hfx/zookeeper/lib
 )
 
 ADD_EXECUTABLE(test ${SRC_LIST})
 #ADD_LIBRARY(zoo_queue SHARED ${SRC_LIST})
 
 TARGET_LINK_LIBRARIES(test zookeeper_mt pthread dl)

 这样便保护了编译好的lib文件

至于如何使用zookeeper 的api
具体的api可以参考官网,也可以参考其他博客,推荐这个:
 http://www.cnblogs.com/haippy/archive/2013/02/21/2920280.html

原创粉丝点击