linux arm64 架构下编译neuron报错 recompile with -fPIC

依赖都已经顺利按照文档安装,make编译阶段报错。

报错如下:
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/…/…/…/aarch64-linux-gnu/libcrypto.a(chacha-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 /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(chacha-armv8.o):(.text+0x20): dangerous relocation: unsupported relocation /usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): relocation R_AARCH64_ADR_PREL_LO21 against symbol poly1305_blocks’ which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/aarch64-linux-gnu/9/…/…/…/aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): in function poly1305_init': (.text+0x40): dangerous relocation: unsupported relocation /usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): relocation R_AARCH64_ADR_PREL_LO21 against symbol poly1305_emit’ which may bind externally can not be used when making a shared object; recompile with -fPIC
(.text+0x48): dangerous relocation: unsupported relocation
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/…/…/…/aarch64-linux-gnu/libcrypto.a(poly1305-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 /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): in function poly1305_emit_neon’:
(.text+0x9a0): dangerous relocation: unsupported relocation
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/…/…/…/aarch64-linux-gnu/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 /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(sha1-armv8.o): in function sha1_block_armv8’:
(.text+0x1240): dangerous relocation: unsupported relocation
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/…/…/…/aarch64-linux-gnu/libcrypto.a(sha256-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 /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(sha256-armv8.o): in function sha256_block_data_order’:
(.text+0xf88): dangerous relocation: unsupported relocation
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/…/…/…/aarch64-linux-gnu/libcrypto.a(sha512-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 /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libcrypto.a(sha512-armv8.o): in function sha512_block_data_order’:
(.text+0x1108): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/neuron-base.dir/build.make:714: libneuron-base.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:311: CMakeFiles/neuron-base.dir/all] Error 2


查资料好像是链接出了问题,但在CMakeLists.txt加了add_compile_options(-fPIC)也不行。

openssl版本是1.1.1f
图片

社区里找到相似问题的,有提及使用openssl1.1.1以上版本

先试试,有结果反馈

openssl换了3以上版本后不报-fPIC了
但报libneuron-base.so: undefined reference to `EVP_PKEY_id’
图片

这没找到解决方式,估计某些依赖版本兼容有问题
换了一个新系统(也还是arm64架构),依赖插件等尽量装新版本后可以编出neuron

自己编译一下openssl版本参考neuron编译文档,openssl的编译加入-fPIC选项