I'm having trouble getting boost python to work with this minimal example. I've emailed the mailing list but have had no response.
I'm using C++20
#include <boost/python.hpp>
#include <iostream>
#include <string>
void printStr(const std::string &testStr) {
std::cout << "BEFORE" <<std::endl;
std::cout << testStr <<std::endl;
std::cout << "AFTER" <<std::endl;
}
BOOST_PYTHON_MODULE(my_module) {
using namespace boost::python;
def("printStr", printStr);
}
This compiles fine, but I get a segmentation fault when I attempt to call the function from python (using 3.10):
import my_module
message = "This is a test"
my_module.printStr(message)
The output I get:
BEFORE
Segmentation fault
Can you tell me what I'm doing wrong? Thanks in advance
I'm having trouble getting boost python to work with this minimal example. I've emailed the mailing list but have had no response.
I'm using C++20
This compiles fine, but I get a segmentation fault when I attempt to call the function from python (using 3.10):
The output I get:
Can you tell me what I'm doing wrong? Thanks in advance