无法将速推库链接到共享库
Cannot link boost library to shared library
将 boost 1.63.0 库libboost_regex-mt.a
链接到共享库时,我收到错误:
/usr/bin/ld: /usr/local/lib/libboost_regex-mt.a(instances.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libboost_regex-mt.a: could not read symbols: Bad value
我实际上已经使用以下命令使用 -fPIC 编译了 boost(另请参阅此处(:
./bjam '-sBUILD=<cxxflags>-fPIC <linkflags>-fPIC' --without-mpi --without-python --without-iostreams --layout=tagged link=shared,static
在进行 bjam 调试构建时,bjam 似乎只尊重某些源文件的-fPIC
,其他文件(包括正则表达式库中的instances.cpp
(在没有它的情况下编译:
gcc.compile.c++ bin.v2/libs/regex/build/gcc-4.8/release/link-static/threading-multi/instances.o
"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -m64 -DBOOST_ALL_NO_LIB=1 -DNDEBUG -I"." -c -o "bin.v2/libs/regex/build/gcc-4.8/release/link-static/threading-multi/instances.o" "libs/regex/build/../src/instances.cpp"
如何强制 bjam 对所有文件使用 -fPIC
标志?
Build boost 1.63,共享库:
./b2 --without-mpi --without-python --without-iostreams --layout=tagged link=shared runtime-link=shared link=static install
线程=多 :
./b2 --without-mpi --without-python --without-iostreams --layout=tagged threading=multi link=shared runtime-link=shared link=static install
"正则表达式"结果:ls *regex*
libboost_regex.a
libboost_regex-mt.a
libboost_regex-mt.so@
libboost_regex-mt.so.1.63.0*
libboost_regex.so@
libboost_regex.so.1.63.0*
相关文章:
- 链接共享库依赖项未在 ldd 中列出
- Gradle cpp 插件不链接共享库
- 从大型 github 项目链接共享库
- 如何在工具ROS中链接共享库
- Linux C++.链接共享对象和主对象
- 共享对象与提升program_options静态链接;应用程序链接共享
- G++ 5.5 不链接共享库
- 根据用户配置在运行时链接共享对象
- 在静态库中链接失败,但链接共享库成功
- G 无法链接共享对象的静态版本
- 仅当标头在 CMake 中更改时,才重新链接共享库
- 动态链接共享库中的全局变量和静态变量会发生什么情况
- CMake:从外部项目链接共享C++对象会生成具有相对路径的二进制文件,而不是绝对路径
- 在VirtualBox的共享文件夹中构建符号链接共享库
- 编译对象后链接共享库时出错
- 如何通过GNU Autotools链接共享库
- 如何以正确的方式编译和链接C/ c++共享对象库
- 无法链接共享对象
- 在 R 包中生成和链接共享库 - 代码编译、链接,但不会加载
- 如何在cmake中链接共享对象