【发布时间】:2012-02-15 20:55:15
【问题描述】:
我一直在尝试在运行时链接和链接静态配置中为 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
Next' 我正在尝试使用具有相同选项的 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
在 Win7 x64 上使用 msvc9 工具集我编译它没有什么大的困难,但我无法在 Ubuntu 上成功。有没有人遇到过类似的问题或知道可能是什么解决方案?任何帮助或线索如何正确构建模块将不胜感激。
干杯
【问题讨论】:
标签: python gcc boost linker ubuntu-10.04