Boost.Python Hello_world示例中的错误(分段故障(核心已转储)”错误)>

问题描述 投票:0回答:1

对于安装,我已按照此过程-> boost-py#installation-for-linux-ubuntu

文件:
  • 'CMakeLists.txt'

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)
  • 'hello.py'
#!/usr/bin/env python

import hello
print (hello.greet())
  • 'hello.cpp'
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 ...

c++ python-3.x boost cmake boost-python
1个回答
0
投票

我找到了解决方案:新的“ CMakeLists.txt”如下:

© www.soinside.com 2019 - 2024. All rights reserved.