版权声明:本文为博主原创文章,未经博主允许不得转载。
ActiveMQ CPP
ActiveMQ CPP是用C++语言访问ActiveMQ的客户端开发库,也称cms(cpp message service),安装cms开发库需要先安装一些基础库。
(1)cppunit
打开http://activemq.apache.org/cms/building.html页面,这里介绍了cms build时用到的依赖库。
cppunit下载页面:
https://sourceforge.net/projects/cppunit/files/cppunit/1.12.1/
这里选择1.12.1版本,获取到下载地址后,在linux下可以用wget命令直接下载,或者下载完成后传到linux系统中。
tar解压后,进入目录,编译三部曲,configure、make、make install(install需要root权限):
./configure --prefix=/usr/local/cppunit/
make
make install
执行完后在/usr/local/cppunit/目录下可以看到头文件和库文件。
(2)apr
apr的全称为Apache Portable Runtime(Apache可移植运行时),Apache旗下有很多开源软件。
apr介绍页面:
http://apr.apache.org/download.cgi
这里选择最新的APR 1.5.2版本,地址为:
http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz
同上,解压进入目录,三部曲:
./configure --prefix=/usr/local/apr/
make
make install
(3)apr-util
这里选择最新的APR-util 1.5.4版本,下载地址为:
http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
解压编译:
./configure --prefix=/usr/local/aprutil --with-apr=/usr/local/apr/
make
make install
(4)apr-iconv
这里选择最新的APR iconv 1.2.1版本,地址为:
http://mirrors.hust.edu.cn/apache//apr/apr-iconv-1.2.1.tar.gz
解压编译:
./configure --prefix=/usr/local/apr-iconv/ --with-apr=/usr/local/apr/
make
make install
(5)openssl
这里选择openssl 1.0.0a版本,下载地址为:
http://www.openssl.org/source/openssl-1.0.0a.tar.gz
解压编译:
./config --prefix=/usr/local/openssl/
make
make install
若出现报错
cms.pod around line 457: Expected text after =item, not a number
在root权限下,执行rm -f /usr/bin/pod2man 然后重新make install
(6)ActiveMQ-CPP
这里选择最新的ActiveMQ-CPP 3.9.3版本,下载页面为:
http://activemq.apache.org/cms/activemq-cpp-393-release.html
解压编译:
./configure --prefix=/usr/local/ActiveMQ-CPP --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/aprutil --with-cppunit=/usr/local/cppunit --with-openssl=/usr/local/openssl
make
make install
若在make时报错,提示找不到ssl库
/usr/bin/ld: cannot find -lssl
进入到 /usr/local/openssl目录,将lib64目录复制一份,复制的新目录名为lib,命令:cp -r lib64 lib,这是由于make时使用的 /usr/local/openssl/lib路径导致。
测试程序
至此编译工作完成,在/usr/local目录下生成了6个目录,分别为ActiveMQ-CPP、apr、apr-iconv、aprutil、cppunit、openssl。
下面编写一段测试代码(test.cpp),用于检测cms开发库是否可用。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
编译命令:
g++ test.cpp -I/usr/local/ActiveMQ-CPP/include/activemq-cpp-3.9.3 -I/usr/local/apr/include/apr-1 -L/usr/local/ActiveMQ-CPP/lib -lactivemq-cpp
其中-I指定了两个include目录,-L指定了一个库目录,-l指定了一个链接库。
运行时,需要将libactivemq-cpp.so、libactivemq-cpp.so.19、libactivemq-cpp.so.19.0.3这3个运行时库复制到/usr/lib64目录下。
GOOD LUCK!!!
转自:http://blog.csdn.net/lgh1700/article/details/51055784