环境运维

安装activemq cpp client的坎坷过程

1、首次执行configure命令,提示:

configure: WARNING: APR not found

The Apache Portable Runtime (APR) library cannot be found.

Please install APR on this system and supply the appropriate

--with-apr option to 'configure'

configure: error: no suitable APR found

2、下载Apache Portable Runtime(apr)

执行如下命令:

 ./configure
   make
   sudo make install

其中make install 必须要用最高权限来执行。

3、继续回到activemq-cpp-library-3.9.5目录,执行

./configure

成功

4、继续在activemq-cpp-library-3.9.5目录执行 

make

出现错误:

decaf/internal/net/ssl/openssl/OpenSSLContextSpi.cpp:42:10: fatal error: 'openssl/ssl.h' file not found

#include <openssl/ssl.h>

         ^~~~~~~~~~~~~~~

1 error generated.

make[2]: *** [decaf/internal/net/ssl/openssl/libactivemq_cpp_la-OpenSSLContextSpi.lo] Error 1

5、输入命令,查看openssl是否已经安装

% openssl version -o

options:  bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx)

% openssl version

LibreSSL 2.8.3

注:以上都是在mac pro下安装的,openssl之前遇到过坑,所以不想再耽误时间,直接换到腾讯云服务器上的centos下继续尝试。

6、换个centos环境,继续在activemq-cpp-library-3.9.5目录执行 

make

报错如下:

collect2: fatal error: ld terminated with signal 9 [Killed]

compilation terminated.

make[2]: *** [Makefile:4617:libactivemq-cpp.la] 错误 1

make[2]: 离开目录“/root/activemq-cpp-library-3.9.5/src/main”

make[1]: *** [Makefile:664:all-recursive] 错误 1

make[1]: 离开目录“/root/activemq-cpp-library-3.9.5”

make: *** [Makefile:535:all] 错误 2

出现以上错误原因是因为磁盘空间不足,在各个文件夹下执行 du -sh * | sort -h 

找到大文件,没用的文件,直接rm了

释放出5G的空间后,继续在activemq-cpp-library-3.9.5目录执行 make命令,成功

7、继续在activemq-cpp-library-3.9.5目录执行  make install 成功

而且各种example也是编译完成,可以直接运行

至此,activemq的c++客户端才有了直观的运行体验。

只是我还没有查看example的具体代码,等研究完了,就可以依样画葫芦,写自己的客户端了,然后就是编译烧写到单片机内运行。。。。。。想想有点小激动。

这里还要跨越.o文件自由调用的坎。

后记:

sh-3.2# sudo sh  example

example: line 202: cd: /root/activemq-cpp-library-3.9.5/src/examples: No such file or directory

clang: error: no such file or directory: '../main/.libs/libactivemq-cpp.so'

clang: error: no such file or directory: '/usr/local/apr/lib/libapr-1.so'

sh-3.2# cd /usr/local/apr/lib/

sh-3.2# ls

apr.exp libapr-1.0.dylib libapr-1.a libapr-1.dylib libapr-1.la pkgconfig     

 

========

删除所有openSSL相关之后,

make 和make install 都成功执行了,也在src/examples成功生成了目标可执行文件

wangyuqiang@wangyuqiangdeMacBook-Pro examples % ls

Makefile chat consumers simple_producer

Makefile.am cmstemplate example stress-test

Makefile.in cmstemplate-stress example-main.o stress_test

advisories cmstemplate_receiver main.cpp tempdest_advisory_consumer

advisory_consumer cmstemplate_sender producers tempdest_advisory_producer

advisory_producer cmstemplate_stress simple_async_consumer topics

但是 运行时报错 

./example

报错:

dyld[63409]: symbol not found in flat namespace (__ZTVN5decaf8internal3net5https12HttpsHandlerE)

zsh: abort      ./example

wangyuqiang@wangyuqiangdeMacBook-Pro examples % ./simple_producer

dyld[63429]: symbol not found in flat namespace (__ZTVN5decaf8internal3net5https12HttpsHandlerE)

zsh: abort      ./simple_producer

针对以上报错,https://stackoverflow.com/questions/54589808/dyld-lazy-symbol-binding-failed-symbol-not-found-expected-in-flat-namespace

上有相同的情况,但是c++基础薄弱,看了文章后,竟然还是不知道如何继续。。。。。

=============================

今天是2023年3月16日

一早继续在mac上折腾

删除了所有与ssl相关的代码。

然后 ./configure --disable-ssl

make (太慢了,几乎用了20分钟以上)

make -j2 (第二次使用,快多了)

然后进入src/examples目录,执行:

./example 

可以正常的收发activemq服务器的消息了。。

至此,mac上算是完整实现了mqtt通讯。只是屏蔽了SSL

在ubuntu上的通讯,昨天已经实现