麒麟V10 arm cpu aarch64 下编译 RocketMQ-Client-CPP 2.2.0

国产自主可控服务器需要访问RocketMQ消息队列,最新的C++SDK是2020年发布的 rocketmq-client-cpp-2.2.0 这个版本支持TLS模式。 用默认的版本安装遇到一些问题,记录一下。

下载Releases · apache/rocketmq-client-cpp · GitHubhttps://github.com/apache/rocketmq-client-cpp/releases

操作系统信息:

#uname -p
aarch64
#uname 
Linux
安装编译需要的工具
#yum install gcc gcc-c++ cmake automake autoconf libtool 

一是默认的boost_1_58_0编译无法通过。检测到的CPU变成了x64,未能检测出arm。使用boost_1_72_0 (更高的版本更改较大,删除了boost_1_72_0.tar.gz\boost_1_72_0\boost\detail\endian.hpp文件,后面编译通不过 )

boost-1_70_0

二是默认的openssl-1.1.1d编译通过,链接时报错:

/usr/bin/ld: ../../bin/lib/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':
(.text+0x1240): dangerous relocation: unsupported relocation

更新为openssl-1.1.1w版本。

三是将依赖的文件解压后放到rocketmq-client-cpp目录

#unzip rocketmq-client-cpp-2.2.0.zip
#mv boost_1_72_0.tar.gz jsoncpp-0.10.7.zip openssl-1.1.1w.tar.gz ./rocketmq-client-cpp-2.2.0

依赖库boost文件可以从 https://sourceforge.net/projects/boost/files/boost/1.72.0/https://sourceforge.net/projects/boost/files/boost/1.72.0/下载。

RocketMQ-Client-CPP2.2.0编译依赖库资源-CSDN文库https://download.csdn.net/download/eamon100/90487665四是修改 CMakeLists.txt,将186至190行注释掉(检测不了aarch64)

186             #    if (CMAKE_BUILD_BITS EQUAL 32)
187             #        list(APPEND CXX_FLAGS "-m32")
188             #    else () #not-condition
189             #        list(APPEND CXX_FLAGS "-m64")
190             #    endif ()

编译:

#./build.sh

编译错误处理:

1、如果出现报错:

Can't locate FindBin.pm in @INC (you may need to install the FindBin module)

需要安装perl和IPC::Cmd模块

yum  install perl-CPAN
cpan IPC::Cmd

2、编译boost报错

thread_data.hpp:60:6: 错误:missing binary operator before token "("

I modified thread_data.hpp to echo the value of PTHREAD_STACK_MIN and it is __sysconf (75).
If I add the following to that file it builds without a problem:

vim ./tmp_down_dir/boost_1_70_0/boost/thread/pthread/thread_data.hpp

#undef PTHREAD_STACK_MIN
#define PTHREAD_STACK_MIN 16384

3、/usr/bin/ld: 找不到 -lz

yum install  zlib-devel

undefined reference to `boost::iostreams::zlib::deflated'

修改build.sh

  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} -sZLIB_INCLUDE="/usr/include" -sZLIB_LIBPATH="/usr/lib64" &> 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} -sZLIB_INCLUDE="/usr/include" -sZLIB_LIBPATH="/usr/lib64"
  fi

重新build 

Performing configuration checks

    - default address-model    : 64-bit (cached)
    - default architecture     : x86 (cached)
    - zlib                     : yes (cached)
    - bzip2                    : no  (cached)
    - lzma                     : no  (cached)
    - zstd                     : no  (cached)
    - iconv (libc)             : yes (cached)
    - icu                      : no  (cached)
    - icu (lib64)              : no  (cached)
    - native-atomic-int32-supported : yes (cached)
    - native-syslog-supported  : yes (cached)
    - pthread-supports-robust-mutexes : yes (cached)
    - has_icu builds           : no  (cached)
    - lockfree boost::atomic_flag : yes (cached)
    - compiler-supports-ssse3  : yes (cached)
    - compiler-supports-avx2   : yes (cached)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值