I'm trying to build python bindings for a library that i wrote, and i'm having some 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 that 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'
This might do the trick :
set(Python_ADDITIONAL_VERSIONS 3.2)
find_package(Boost COMPONENTS system thread python-py32 REQUIRED)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With