繁体   English   中英

在Ubuntu x64上与静态Boost :: Python库链接时出错

[英]Error linking with static Boost::Python library on Ubuntu x64

我一直在尝试在运行时链接中为x64 linux构建一个小的Python模块,并链接静态配置,不幸的是没有成功。 我在具有gcc 4.4.3和Python 2.6.5环境的Ubuntu x64 10.04上使用Boost :: Python v.1.47。

我已经使用b2手动构建了Boost :: Python,并且选项设置为没有问题:

toolset=gcc variant=release address-model=64 link=static runtime-link=static

接下来,我正在尝试使用具有相同选项的bjam构建模块(pydsrc.cpp),但在gcc链接器阶段失败。 以下是构建阶段的最后几行:

...
gcc.compile.c++ ../bin.v2/libs/python/build/gcc-4.4.3/release/address-model-64/link-static/runtime-link-static/object/function_doc_signature.o
gcc.archive ../bin.v2/libs/python/build/gcc-4.4.3/release/address-model-64/link-static/runtime-link-static/libboost_python.a
gcc.link.dll bin/gcc-4.4.3/release/address-model-64/link-static/runtime-link-static/pydsrc.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtbeginT.o: relocation R_X86_64_32 against `__DTOR_END__' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtbeginT.o: could not read symbols: Bad value
collect2: ld returned 1 exit status

"g++"    -o "bin/gcc-4.4.3/release/address-model-64/link-static/runtime-link-static/pydsrc.so" -Wl,-h -Wl,pydsrc.so -shared -Wl,--start-group "bin/gcc-4.4.3/release/address-model-64/link-static/runtime-link-static/pydsrc.o" 
 "../bin.v2/libs/python/build/gcc-4.4.3/release/address-model-64/link-static/runtime-link-static/libboost_python.a"   -lutil -lpthread -ldl   -Wl,--end-group -static -m64

在使用msvc9工具集的Win7 x64上,我对其进行编译没有很大困难,但是在Ubuntu上我无法成功。 有没有人遇到类似的问题或知道什么是解决方案? 任何帮助或提示如何正确构建模块将不胜感激。

干杯

尝试通过cxxflags指令包含PIC(与位置无关的代码)编译标志。 因此,在您的情况下,例如:

toolset=gcc variant=release address-model=64 cxxflags=-fPIC link=static runtime-link=static

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM