[C++-sig] trouble initializing module using Boost
J.D. Yamokoski
yamokosk at ufl.edu
Thu Jun 1 21:00:50 CEST 2006
I have run into a compile error which is probably very easy to fix. I am
trying to call PyImport_AppendInittab() to add the initialization of a
module I have created with Boost. The exact details are of the call are:
// Register the extension module
if ( PyImport_AppendInittab("shapes", initshapes) == -1 ) {
throw python_exception( "Failed to add shapes to the interpreter's
builtin modules" );
}
// Initialize the Python interpreter
Py_Initialize();
....
I believe the module is defined correctly - I have used the module in
the Python command line, just now trying to use it through the C-API.
Here is the definition:
---- BoxModule.h ----
#include <boost/python.hpp>
#include "Box.h"
using namespace boost::python;
---- BoxModule.cpp ----
#include "BoxModule.h"
BOOST_PYTHON_MODULE(shapes)
{
class_<Box>("MyBox")
.add_property("height", &Box::getHeight, &Box::setHeight)
.add_property("width", &Box::getWidth, &Box::setWidth)
.add_property("length", &Box::getLength, &Box::setLength)
.add_property("volume", &Box::getVolume, &Box::setVolume);
}
And finally, the compile error message is:
error C2065: 'initshapes' : undeclared identifier
So is initshapes put in a namespace? Or how do I pass this function to
PyImport_AppendInittab()?
More information about the Cplusplus-sig
mailing list