
rocketmq-client-cpp 2.0.1 编译方法(基于 ARM 64 架构)
近期,博主同事在进行业务容器适配 ARM 64 的工作,但是遇到无法安装 rocketmq-client-cpp 2.0.1 动态库的问题,最终博主帮忙解决了该问题。该问题的原因是 X86 架构下可以直接使用官方 yum 源进行安装,但是 ARM 64 架构下官方并未提供 yum 源。
本文基于 rocketmq-client-cpp 2.0.1 版本,通过源码编译方式生成 .so 动态库文件,以下为完整过程。
1、安装依赖(解决报错1)
yum install -y gcc-c++ cmake automake autoconf libtool bzip2-devel zlib-devel
2、下载 & 解压
cd
wget -O rocketmq-client-cpp-2.0.1.tar.gz https://github.com/apache/rocketmq-client-cpp/archive/refs/tags/2.0.1.tar.gz
tar -xzf rocketmq-client-cpp-2.0.1.tar.gz && cd rocketmq-client-cpp-2.0.1
3、修改 build.sh(解决报错2)
# 在函数 BuildBoost 中加入 >>>>>> <<<<<< 之间的内容
BuildBoost() {
if [ $need_build_boost -eq 0 ]; then
echo "no need build boost lib"
return 0
fi
cd ${down_dir}
if [ -e ${fname_boost} ]; then
echo "${fname_boost} is exist"
else
wget http://sourceforge.net/projects/boost/files/boost/${fname_boost_down}
fi
tar -zxvf ${fname_boost} &> unzipboost.txt
boost_dir=$(ls | grep ^boost | grep .*[^gz]$)
cd ${boost_dir}
if [ $? -ne 0 ]; then
exit 1
fi
./bootstrap.sh
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
./b2 &>/dev/null # 需要先运行 ./b2 以生成 /root/rocketmq-client-cpp-2.0.1/tmp_down_dir/boost_1_58_0/bin.v2 目录
sleep 5
rm -rf /root/rocketmq-client-cpp-2.0.1/tmp_down_dir/boost_1_58_0/bin.v2/project-cache.jam
cp -p /root/project-cache.jam /root/rocketmq-client-cpp-2.0.1/tmp_down_dir/boost_1_58_0/bin.v2/project-cache.jam
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
if [ $? -ne 0 ]; then
exit 1
fi
echo "build boost static #####################"
pwd
if [ $verbose -eq 0 ]; then
echo "build boost without detail log."
./b2 -j$cpu_num cflags=-fPIC cxxflags=-fPIC --with-atomic --with-thread --with-system --with-chrono --with-date_time --with-log --with-regex --with-serialization --with-filesystem --with-locale --with-iostreams threading=multi link=static release install --prefix=${install_lib_dir} &> boostbuild.txt
else
./b2 -j$cpu_num cflags=-fPIC cxxflags=-fPIC --with-atomic --with-thread --with-system --with-chrono --with-date_time --with-log --with-regex --with-serialization --with-filesystem --with-locale --with-iostreams threading=multi link=static release install --prefix=${install_lib_dir}
fi
if [ $? -ne 0 ]; then
exit 1
fi
}
4、修改 CMakeLists.txt(解决报错2)
sed -i "s/list(APPEND CXX_FLAGS \"-m64\")/#list(APPEND CXX_FLAGS \"-m64\")/g" CMakeLists.txt
grep "m64" CMakeLists.txt
5、修改 project-cache.jam(解决报错2)
# 将以下 3 行改为 true(获取文件方法:第一次执行 build.sh 脚本,失败退出后复制/root/rocketmq-client-cpp-2.0.1/tmp_down_dir/boost_1_58_0/bin.v2/project-cache.jam)
module config-cache {
...
set "arm-<target-os>linux-<toolset-gcc:version>4.8.5-<toolset>gcc" : "true" ;
...
set "arm-<address-model>64-<target-os>linux-<toolset-gcc:version>4.8.5-<toolset>gcc" : "true" ;
...
set "gcc visibility-<address-model>64-<target-os>linux-<toolset-gcc:version>4.8.5-<toolset>gcc" : "true" ;
...
}
6、执行脚本
bash build.sh
# 生成的文件位于 /root/rocketmq-client-cpp-2.0.1/bin 目录
附录
报
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 咸鱼博客
评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果