when compiling shared library which links boost and python libraries I receive error:
/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
I've used verbose mode to look at compiler definitions:
/usr/bin/c++ -fPIC -g -shared -Wl,-soname,libCore.so -o .../libCore.so Core.cpp.o -lpython2.7 -Wl,-Bstatic -lboost_python -Wl,-Bdynamic
That's it! I have to remove -Wl, -Bstatic
from definitions but how to do that? I'm using cmake build system and here is a part of code which generates that shared library:
set(Core_SRC
Core.cpp
)
add_definitions(-g -fPIC)
add_library(Core SHARED ${Core_SRC})
target_link_libraries(Core
${PYTHON_LIBRARIES}
${Boost_LIBRARIES}
)