For Installation, I have followed this procedure --> boost-py#installation-for-linux-ubuntu
Files:
- '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);
}
Basically, I am following this repo: TNG/boost-python-examples
Building, Execution:
On running via bash terminal, I am getting "Segmentation Fault (core dumped)" on running $ ./hello.so or $ 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$
I have been trying to resolve this error. I referred to many solutions, but couldn't solve my one. Can anyone help please?? It's really IMPORTANT!!!...
THANKS!!
.sofiles. That is one problem.char const*which looks wrong... do you meanconst char*?