I am trying to create python bindings for the library that I wrote, and I am having trouble getting cmake to understand that it should use the boost-python library for python 3.
Here is my cmake file:
cmake_minimum_required(VERSION 2.8) FIND_PACKAGE(Boost COMPONENTS system thread python REQUIRED) find_package(PythonLibs REQUIRED) INCLUDE_DIRECTORIES(${PYTHON_LIBRARIES}) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) ADD_LIBRARY( pschulze SHARED src/candidate_relation.cpp src/schulze.cpp src/calculate.cpp src/candidate.cpp src/ranking.cpp src/userinput.cpp python.cpp) TARGET_LINK_LIBRARIES(pschulze ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) ADD_EXECUTABLE( schulze src/candidate_relation.cpp src/schulze.cpp src/calculate.cpp src/candidate.cpp src/ranking.cpp src/userinput.cpp src/json-spirit/json_spirit_reader.cpp src/json-spirit/json_spirit_value.cpp main.cpp) TARGET_LINK_LIBRARIES(schulze ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) ADD_DEFINITIONS(-std=gnu++0x -Os) add_subdirectory (tests) set(CMAKE_BUILD_TYPE Debug)
And this is the linker error I get:
Linking CXX executable schulze CMakeFiles/schulze.dir/src/schulze.cpp.o: In function `arg_to_python': /usr/include/boost/python/converter/builtin_converters.hpp:122: undefined reference to `PyInt_FromLong' /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libboost_python.so: undefined reference to `PyString_Size'
c ++ python boost cmake
Alexander Kjรคll
source share