Hi all I trying to build python swig wrapper with CMake. And I have following issues during make:
/usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(CMAKE_SWIG_FLAGS "-Wall" "-c++")
SET_SOURCE_FILES_PROPERTIES(feature.i PROPERTIES CPLUSPLUS ON)
SET_SOURCE_FILES_PROPERTIES(feature.i PROPERTIES SWIG_FLAGS "-includeall")
SWIG_ADD_MODULE(feature_wrapper python feature.i)
SWIG_LINK_LIBRARIES(feature_wrapper ${PYTHON_LIBRARIES})
In your CMakeLists.txt
file, add the following line:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
And replace the following line with:
SWIG_ADD_MODULE(feature python feature.i feature.cxx)
SWIG_LINK_LIBRARIES(feature ${PYTHON_LIBRARIES})
Then you can check it out by doing
python
>>> import feature
>>> print dir(feature)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.