I am trying to reproduce the Boost.Python tutorial on how to do a wrap a C/C++ file for python.
This is the cpp file which builded successfuly.
#include "boost/python.hpp"
class SaySomething
{
public:
void set(std::string msg)
{
this->msg = msg;
}
std::string greet()
{
return msg;
}
std::string msg;
};
BOOST_PYTHON_MODULE(SaySomething)
{
namespace python = boost::python;
python::class_<SaySomething>("SaySomething")
.def("greet", &SaySomething::greet)
.def("set", &SaySomething::set)
;
}
In the same directory of the source code I have the python file
import SaySomething
msg = SaySomething.SaySomething()
msg.set('howdy')
msg.greet()
When I try to run the python file this error occurs
ModuleNotFoundError: No module named 'SaySomething'
I tried moving the compiled library to the same folder with no success. The tutorial doesn't elaborate on how to make the C++ file seen by the interpreter.
Edit
As some have suggested I have edited the extension of the compiled shared library to .pyd so python can see it. This creates a second error
ImportError: DLL load failed: The specified module could not be found.
This issue is exactly like mine. The solution suggests to add Boost.python to environnement variable. I know how to add path to this but I'm not sure what path I want, the boost.python dlls (or lib)? Just boost?