摘要: zookeeper C API 的安装和使用指南 "zookeeper C API 的安装和使用指南": 关键词:zookeeper c api 安装 使用指南 1 下载 zookeeper

来源:互联网 发布:农业 生长 大数据 编辑:程序博客网 时间:2024/06/06 01:02
摘要: zookeeper C API 的安装和使用指南
"zookeeper C API 的安装和使用指南":关键词:zookeeperc api 安装 使用指南

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.makaidong.com/haippy/archive/2013/02/21/2920280.html

原创粉丝点击