静态地提升python构建

时间:2018-06-18 10:56:18

标签: c++ boost-python

我搜索了如何静态构建,但我仍然在努力运行它。比如这个Static linking with boost python,我越来越错误了

  

/ python_boost $ g ++ -o hello.o -c hello.cpp -Wall -fPIC       -I / usr / include / python2.7 / python_boost $ g ++ -shared -o libhello.so hello.o -lpython2.7 /usr/lib/x86_64-linux-gnu/libboost_python.a   在/ usr / bin中/ LD:   /usr/lib/x86_64-linux-gnu/libboost_python.a(from_python.o):搬迁   制作a时,不能使用R_X86_64_32对.`rodata.str1.8'   共享对象;用-fPIC重新编译   /usr/lib/x86_64-linux-gnu/libboost_python.a:错误添加符号:错误   value collect2:error:ld返回1退出状态

我做错了什么?

1 个答案:

答案 0 :(得分:1)

Object files intended to be linked into a shared library must be compiled as position-independent code. With gcc and clang that requires -fPIC compiler command line option. Static .a libraries are normally compiled without that option and that is the reason you observe this linker error. See How to compile static library with -fPIC from boost.python for more details.