linux activemq-cpp編譯

僅作爲編譯記錄

http://blog.csdn.net/lgh1700/article/details/51055784

http://activemq.apache.org/cms/building.html

依賴庫version

cppunit-1.14.0.tar.gz

apr-1.6.2.tar.gz

apr-util-1.6.0.tar.gz

apr-iconv-1.2.1.tar.gz

e2fsprogs-1.43.6.tar.gz

expat-2.1.0.tar.gz(maybe not need)

openssl-1.0.0a.tar.gz(openssl-1.1.0f.tar.gz compile not pass):http://www.linuxidc.com/Linux/2011-10/45738.htm

zlib-1.2.11.tar.gz

activemq-cpp-library-3.9.4-src.tar.gz

步驟

ActiveMQ CPP

ActiveMQ CPP是用C++語言訪問ActiveMQ的客戶端開發庫,也稱cms(cpp message service),安裝cms開發庫需要先安裝一些基礎庫。

1、sudo apt-get install autoconf automake libtool

(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
ps:可以用系統自帶的,則下面編譯activemq時將目錄替換爲相應路徑

這裏選擇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

./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路徑導致。

二、編譯安裝 OpenSSL

2.1、準備工作

系統版本:Ubuntu-10.10-Server-I386
更新源:apt-get update
升級軟件:apt-get upgrade
更新系統:apt-get dist-upgrade

2.2、查看OpenSSL版本

部分 Linux 系統已默認安裝了 OpenSSL 0.9.8,特別是 VPS 一般都安裝了。

1
openssl version -a
2.3、安裝基礎編譯環境

1
apt-get install build-essential
2.3、編譯安裝 Zlib 庫

wget http://zlib.net/zlib-1.2.5.tar.gz
tar -zxf zlib-1.2.5.tar.gz
cd zlib-1.2.5/
./configure –prefix=/usr/local
make && make install
2.4、卸載舊版本 OpenSSL

apt-get purge openssl
rm -rf /etc/ssl #刪除配置文件
2.5、編譯與安裝 OpenSSL

prefix 是安裝目錄,openssldir 是配置文件目錄,另外建議安裝兩次,shared 作用是生成動態連接庫。

wget ftp://ftp.openssl.org/source/openssl-1.0.0c.tar.gz
tar -zxf openssl-1.0.0c.tar.gz
cd openssl-1.0.0c/
./config –prefix=/usr/local –openssldir=/usr/local/ssl
make && make install
./config shared –prefix=/usr/local –openssldir=/usr/local/ssl
make clean
make && make install

http://blog.csdn.net/chenxun_2010/article/details/52709277

編譯舉例

代碼官網有例子
g++ producer.cpp -o send -I/usr/local/ActiveMQ-CPP/include/activemq-cpp-3.9.4 -I/usr/local/apr/include/apr-1 -L/usr/local/ActiveMQ-CPP/lib -lactivemq-cpp

g++ consumer.cpp -o consumer -I/usr/local/ActiveMQ-CPP/include/activemq-cpp-3.9.4 -I/usr/local/apr/include/apr-1 -L/usr/local/ActiveMQ-CPP/lib -lactivemq-cpp

export LD_LIBRARY_PATH=/usr/local/lib

export JAVA_HOME=/usr/share/jdk1.6.0_14
export PATH=JAVAHOME/bin: PATH
export CLASSPATH=.:JAVAHOME/lib/dt.jar: JAVA_HOME/lib/tools.jar

source /etc/profile

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章