cpp proj中没有这样的文件pyconfig.h

时间:2019-06-11 08:02:46

标签: python c++ boost clion boost-python

因此,我正在尝试将一些python代码集成到c ++项目中。为此,我使用clion创建了简单的测试项目。但是遇到了问题。在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

看到了一些解决方案,例如:

  

”添加导出   CPLUS_INCLUDE_PATH =“ $ CPLUS_INCLUDE_PATH:/usr/include/python2.7/”到   bashrc”。

尝试过-没有。

这是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看起来像这样

#include <iostream>

#include <boost/python.hpp>

int main() {

}

感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

嗯,这有点儿联系问题。解决了对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})