Below is a very simple extension, mostly cut from the provided example. It compiles and builds the cinterpreter.pyd without error, but when I do the following in python:
import cinterpreter
I get this result:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initcinterpreter)
I looked over the example again and again, and I simply cannot see what the problem is. What is wrong?
***********************************************************
#ifdef _MSC_VER
// disable warning C4786: symbol greater than 255 character,
// nessesary to ignore as <map> causes lots of warning
#pragma warning(disable: 4786)
#endif
#include "CXX/Objects.hxx"
#include "CXX/Extensions.hxx"
#include <assert.h>
#include <algorithm>
#include <iostream>
class cinterpreter_module : public Py::ExtensionModule<cinterpreter_module>
{
public:
cinterpreter_module()
: Py::ExtensionModule<cinterpreter_module>( "cinterpreter" )
{
add_varargs_method("test", &cinterpreter_module::c_test, "test() is just a test.");
initialize( "cinterpreter module initialize." );
Py::Dict d( moduleDictionary() );
}
virtual ~cinterpreter_module() {}
private:
Py::Object c_test(const Py::Tuple &args) {
std::cout << "c_test() called." << std::endl;
return Py::None();
}
};
extern "C" void initcinterpreter()
{
#if defined(PY_WIN32_DELAYLOAD_PYTHON_DLL)
Py::InitialisePythonIndirectPy::Interface();
#endif
static cinterpreter_module* cinterpreter = new cinterpreter_module;
}
// symbol required for the debug version
extern "C" void initcinterpreter_d()
{ initcinterpreter(); }
_________________________________________________________________
Try Chicktionary, a game that tests how many words you can form from the letters given. Find this and more puzzles at Live Search Games!
http://g.msn.ca/ca55/207 |