relocation R_X86_64_PC32 against symbol can not be used when making a shared object; recompile with -fPIC
项目需要链接absl,absl默认编译为静态库,但项目编译为动态库,动态库不能链接静态库,编译时报错
relocation R_X86_64_PC32 against symbol can not be used when making a shared object; recompile with -fPIC
- 解决办法1
为abslCMakeLists.txt
添加编译选项,重新编译安装absl
set(CMAKE_CXX_FLAGS "-fPIC")
or
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
- 解决办法2
将absl编译为动态库,cmake
编译时设置-DBUILD_SHARED_LIBS=ON