简体   繁体   English

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

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

I've been trying to build a small Python module for x64 linux in runtime-link and link static configuration and unfortunately with no success. 我一直在尝试在运行时链接中为x64 linux构建一个小的Python模块,并链接静态配置,不幸的是没有成功。 I'm using using Boost::Python v.1.47 on Ubuntu x64 10.04 with gcc 4.4.3 and Python 2.6.5 environment. 我在具有gcc 4.4.3和Python 2.6.5环境的Ubuntu x64 10.04上使用Boost :: Python v.1.47。

I've build Boost::Python manually using b2 with no problems with options set to: 我已经使用b2手动构建了Boost :: Python,并且选项设置为没有问题:

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

Next' I'm trying to build my module (pydsrc.cpp) using bjam with the same options, but it fails at the gcc linker stage. 接下来,我正在尝试使用具有相同选项的bjam构建模块(pydsrc.cpp),但在gcc链接器阶段失败。 Below are the last lines from the build stage: 以下是构建阶段的最后几行:

...
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

On Win7 x64 using msvc9 toolset I compiled it with no major difficulties, but I cannot success on Ubuntu. 在使用msvc9工具集的Win7 x64上,我对其进行编译没有很大困难,但是在Ubuntu上我无法成功。 Has anyone come across similar problem or know what might be a solution? 有没有人遇到类似的问题或知道什么是解决方案? Any help or clue how to properly build the module would be greatly appreciated. 任何帮助或提示如何正确构建模块将不胜感激。

Cheers 干杯

Try include the PIC (position-independent code) compile flag via the cxxflags directive. 尝试通过cxxflags指令包含PIC(与位置无关的代码)编译标志。 So in your case something like: 因此,在您的情况下,例如:

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

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

相关问题 将静态库链接到Boost Python(共享库)中-导入错误 - Linking a static library into Boost Python (shared library) - Import Error Windows x64中的python calg库 - python calg library in windows x64 Boost.Python + opencv Error, Windows 10 x64, "ImportError: DLL load failed: The specified module could not be found." - Boost.Python + opencv Error, Windows 10 x64, "ImportError: DLL load failed: The specified module could not be found." C ++链接到python 3.2 x64应用程序无法加载 - C++ linking to python 3.2 x64 application unable to load 链接python_boost.lib时,Visual Studio 2017“与静态运行时混合DLL Boost库” - Visual Studio 2017, “Mixing a dll boost library with a static runtime”, when linking python_boost.lib python x64中的编码问题 - Encoding problems in python x64 在Windows x64上编译Python模块 - Compiling Python modules on Windows x64 Python 2.7在$ LD_LIBRARY_PATH(OpenSUSE 12.1 x64)中不查找.so库 - Python 2.7 doesn't look for .so libs in $LD_LIBRARY_PATH (OpenSUSE 12.1 x64) 在Windows x64上安装libpng时出错 - Error in installing libpng for windows x64 HDF5 库版本与 Windows x64 的最新 Tensorflow 版本不匹配错误 - HDF5 library version mismatched error with latest Tensorflow build for windows x64
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM