簡體   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