2012-02-15 96 views
0

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

我已经建立的boost ::使用Python B2没有问题的选项设置为手动:

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工具集,我没有什么大的困难编译它X64 Win7的,但我不能在Ubuntu的成功。有没有人遇到类似的问题或知道什么可能是一个解决方案?任何帮助或线索如何正确地建立模块将不胜感激。

干杯

回答

1

尝试包括PIC(与位置无关的代码)经由CXXFLAGS指令编译的标志。所以在你的情况是这样的:

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

我试过这也与重新编译增强库与fPIC - 不幸没有运气。我已经放弃并且放弃了编译我的模块的静态版本,但是感谢你的回答。 – stx 2012-05-29 11:37:33