首页 > 编程语言 >C++编译问题,解决arm下链接静态库,引起的relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol错误

C++编译问题,解决arm下链接静态库,引起的relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol错误

时间:2023-01-09 14:58:36浏览次数:45  
标签:PREL ADR AARCH64 fPIC relocation against 编译 PG 链接

显示的完整错误如下:

relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `ZN2c43yml9free_implEPvmS1' which may bind externally can not be used when making a shared object; recompile with -fPIC

根据提示,在链接.a静态库时,应该在编译时加上参数-fPIC

然而CMake文件中已经有了

add_compile_options(-fPIC)

导致这个问题的根本原因在于,链接的.a文件在编译时没有加上-fPIC参数

所以找到.a文件的源码,并在编译时加上-fPIC,在链接时就没问题了

标签:PREL,ADR,AARCH64,fPIC,relocation,against,编译,PG,链接
From: https://www.cnblogs.com/umichan0621/p/17037032.html

相关文章