編譯哪個環節提升和Python庫共享庫,當我收到錯誤:刪除編譯器定義
/usr/bin/ld: libboost_python.a(from_python.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC libboost_python.a: could not read symbols: Bad value
我用詳細模式來看看編譯器的定義:
/usr/bin/c++ -fPIC -g -shared -Wl,-soname,libCore.so -o .../libCore.so Core.cpp.o -lpython2.7 -Wl,-Bstatic -lboost_python -Wl,-Bdynamic
這就是它!我必須從定義中刪除-Wl, -Bstatic
但如何做到這一點?我使用cmake構建系統,這裏是代碼的一部分,其產生的共享庫:
set(Core_SRC
Core.cpp
)
add_definitions(-g -fPIC)
add_library(Core SHARED ${Core_SRC})
target_link_libraries(Core
${PYTHON_LIBRARIES}
${Boost_LIBRARIES}
)
1.加速Python模塊不能非共享庫? 2.我不能建造它,因爲我對這個3.對不起限制,無法理解 – Ockonal 2012-07-17 13:16:57
本:「重新編譯-fPIC libboost_python.a」是告訴你,你需要做什麼。如果不能重建libbost_python.a,那麼你的庫不能共享。 想必你的編譯系統建立在輪候冊給力,-Bstatic出於某種原因。如果沒有,你應該有你的構建系統的維護者一個字,看看他們是否能解釋爲什麼 – 2012-07-17 13:25:41