您的位置:首页 > 其它

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

2017-09-11 16:36 966 查看
摘要: zookeeper C API 的安装和使用指南

"zookeeper C API 的安装和使用指南":关键词zookeeper

c
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: