对于安装,我已按照此过程-> boost-py#installation-for-linux-ubuntu
cmake_minimum_required(VERSION 3.0)
find_package(Boost COMPONENTS python36 required)
find_package(PythonInterp 3)
find_package(PythonLibs 3)
PYTHON_ADD_MODULE(hello hello.cpp)
include_directories(/usr/include/python3.6m)
FILE(COPY hello.py DESTINATION .)
add_test(NAME 01-HelloWorld COMMAND ${PYTHON_EXECUTABLE} hello.py)
#!/usr/bin/env python
import hello
print (hello.greet())
char const* greet() { return "hello, world"; } #include <boost/python.hpp> BOOST_PYTHON_MODULE(hello) { using namespace boost::python; def("greet", greet); }
基本上,我正在关注此仓库:TNG/boost-python-examples
[通过bash
终端运行时,在运行$ ./hello.so
或$ python hello.py
时出现“分段故障(内核已转储)”
abhi3700@Abhijit:/mnt/f/Coding/github_repos/cpp-playground/gitcpplibs/boost-py-eg/01-HelloWorld$ cmake . -- Boost found. -- Found Boost components: python36;required -- Configuring done -- Generating done -- Build files have been written to: /mnt/f/Coding/github_repos/cpp-playground/gitcpplibs/boost-py-eg/01-HelloWorld abhi3700@Abhijit:/mnt/f/Coding/github_repos/cpp-playground/gitcpplibs/boost-py-eg/01-HelloWorld$ make [100%] Built target hello abhi3700@Abhijit:/mnt/f/Coding/github_repos/cpp-playground/gitcpplibs/boost-py-eg/01-HelloWorld$ ./hello.so Segmentation fault (core dumped) abhi3700@Abhijit:/mnt/f/Coding/github_repos/cpp-playground/gitcpplibs/boost-py-eg/01-HelloWorld$ python3 hello.py Segmentation fault (core dumped) abhi3700@Abhijit:/mnt/f/Coding/github_repos/cpp-playground/gitcpplibs/boost-py-eg/01-HelloWorld$
我一直在尝试解决此错误。我提到过许多解决方案,但无法解决我的问题。谁能帮忙吗?这真的很重要!! ...
谢谢!
对于安装,我已按照此过程-> boost-py#installation-for-linux-ubuntu文件:'CMakeLists.txt'cmake_minimum_required(VERSION 3.0)find_package(Boost COMPONENTS python36 ...
我找到了解决方案:新的“ CMakeLists.txt”如下: