I have small cpp program:
#include <iostream>
#include <boost/python.hpp>
//#include <boost/python/numpy.hpp>
void helloxd(){
std::cout<<std::endl<<"something"<<std::endl;
}
BOOST_PYTHON_MODULE(tkbd_cpp)
{
using namespace boost::python;
def("helloxd_cpp", helloxd);
}
I'm using cmake to compile it to run as python 3 library. Im using this CMakeLists.txt
cmake_minimum_required( VERSION 3.5 )
project( tkbd_cpp )
set(CMAKE_CXX_FLAGS "-Wl,--no-undefined")
set(BOOST_ROOT /usr/boost)
set(PYTHON_LIBRARY /usr/lib/python3.5 )
set(PYTHON_INCLUDE_DIR /usr/include/python3.5m )
find_package(PythonInterp 3.5 REQUIRED)
find_package(PythonLibs 3.5 REQUIRED)
find_package(Boost 1.54 REQUIRED COMPONENTS system python)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} )
ADD_LIBRARY(tkbd_cpp SHARED py_wrapper.cpp)
TARGET_LINK_LIBRARIES(tkbd_cpp ${Boost_LIBRARIES} ${PythonLibs_LIBRARIES})
set_target_properties( tkbd_cpp PROPERTIES PREFIX "" )
I can succesfully run cmake ., but when i try to run make command i get
CMakeFiles/tkbd_cpp.dir/py_wrapper.cpp.o: In function `PyInit_tkbd_cpp':
py_wrapper.cpp:(.text+0xcf): undefined reference to `boost::python::detail::init_module(PyModuleDef&, void (*)())'
CMakeFiles/tkbd_cpp.dir/py_wrapper.cpp.o: In function `boost::python::detail::none()':
py_wrapper.cpp:(.text._ZN5boost6python6detail4none
I tried reinstalling boost several times, with few methods, with --with-python=python3.5m argument, compiling by hand with g++, runing example from https://github.com/TNG/boost-python-examples , and every time I get undefined reference. I use linux, and default python is python 3.5. I read all answers connected with boost-python on stack-overflow and non of them helped me. What else could I try?