Search code examples
pythonc++boostclionboost-python

No such file pyconfig.h in cpp proj


So, I'm trying to integrate some python code to c++ project. For that purpose I've created simple test project using clion. But met with a problem. Working on OS - Ubuntu 18.04.2

"/usr/include/boost/python/detail/wrap_python.hpp:50:11: fatal error: pyconfig.h: No such file or directory" on the line 

include boost/python.hpp

Seen some solutions like:

"add export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/include/python2.7/" to bashrc".

Tried that - nothing.

Here is the cmakelist

cmake_minimum_required(VERSION 3.14)
project(pythonInCPPIntegration)

set(CMAKE_CXX_STANDARD 14)
find_package(Boost 1.65.1 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(pythonInCPPIntegration main.cpp)
target_link_libraries(pythonInCPPIntegration ${Boost_LIBRARIES})

C-proj looks like that, nothing more

#include <iostream>

#include <boost/python.hpp>

int main() {

}

Appreciate any help!


Solution

  • Well, it was kinda linkage problem. Solved with some manipulations over cmakelists.txt

    cmake_minimum_required(VERSION 3.14)
    project(pythonInCPPIntegration)
    
    set(CMAKE_CXX_STANDARD 14)
    find_package(Boost 1.65.1 COMPONENTS system filesystem REQUIRED)
    find_package(PythonLibs)
    include_directories(${Boost_INCLUDE_DIRS})
    include_directories(${PYTHON_INCLUDE_PATH})
    add_executable(pythonInCPPIntegration main.cpp)
    target_link_libraries(pythonInCPPIntegration ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})