I'm fairly new to using Boost Python and running into some funkiness. When I try to pass back a simple int from C++ to Python, I get a Segmentation Fault. Here's the C++:
#include <iostream>
#include <boost/python.hpp>
int helloworld()
{
return 10;
}
BOOST_PYTHON_MODULE(test_boost)
{
boost::python::def("helloworld", helloworld);
}
and here's the Python:
import test_boost
print(test_boost.helloworld())
The strange thing is it works fine with char const* types. Does anyone know what could cause this?
Compiled on Mac OS X 10.10.5 with Anaconda Python with the following:
g++ -g -shared -fPIC -I/Users/bradneuberg/anaconda/include/python2.7 test_boost.cpp -lpython2.7 -lboost_python -o test_boost.so
Best,
Brad Neuberg