1.环境
系统版本:Linux 5.4.18-87.76-generic KYLINOS SMP Thu Aug 31 09:05:44 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
GCC: gcc (Ubuntu 9.3.0-10kylin2) 9.3.0
G++: g++ (Ubuntu 9.3.0-10kylin2) 9.3.0
RocketMQ服务端版本:5.1.1
RocketMQ-cpp 版本最新版2.2.0
2.下载源码
wget https://codeload.github.com/apache/rocketmq-client-cpp/zip/refs/master
下载下来为最新版本2.2.0
3.安装依赖
主要需要这几个依赖包
automake 1.11.1: build libevent require it
autoconf 2.65: build libevent require it
libtool 2.2.6: build libevent require it
sudo apt-get update
sudo apt-get install automake
sudo apt-get install autoconf
sudo apt-get install libtool
4.开始编译
官方执行 sh build.sh ARM 下sh 会报错可以替换为bash build.sh
openssl-1.1.1d.tar.gz
libevent-release-2.1.11-stable.zip
jsoncpp-0.10.7.zip
boost_1_78_0.tar.gz
依赖这几个库,如果没有脚本自动会下载进行编译。
下载编译比较耗时。
5. 问题
5.1 libjsoncpp.a 找不到
因为jsoncpp 编译后会生成在rocketmq-client-cpp-master\bin\lib\aarch64-linux-gnu\这个路径下,编译读取路径为rocketmq-client-cpp-master\bin\lib,所以需要自己手动从aarch64-linux-gnu下拷贝到rocketmq-client-cpp-master\bin\lib . X86 机器下好像没有这个问题。
5.2 unrecognized command line option '-m64'
修改rocketmq-client-cpp-master/CMakeLists.txt
注释掉 因为ARM 下GCC 不支持该编译选项
5.3 Openssl aarch64 libcrypto.a(sha1-armv8.o) relocation R_AARCH64_PREL64 against symbol 'OPENSSL_armcap_P' which may bind externally can not be used when making a shared object ; recompile with -fPIC ../../bin/lib/libcrypto.a(sha1-armv8.o) : in function ' sha1-block_armv8'
rocketmq-client-cpp-master/tmp_down_dir/openssl-1.1.1d/crypto/poly1305/asm/poly1305-armv8.pl
rocketmq-client-cpp-master/tmp_down_dir/openssl-1.1.1d/crypto/sha/asm/sha1-armv8.pl