From: <hap...@ho...> - 2008-08-01 07:13:51
|
An update: The same import error also happens with the debug versions of the example module in the Demo. So I added extern "C" void initexample_d(); to python.cxx. This built, but when import example_d with python, same problem. So then I added initexample_d to the EXPORTS in the export definition file, which built fine, but same problem. This is on Vista, with Visual C++. From: hap...@ho...To: cxx...@li...Subject: Date: Thu, 31 Jul 2008 17:04:17 -0700 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 cinterpreterI 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 versionextern "C" void initcinterpreter_d(){ initcinterpreter(); } _________________________________________________________________ If you like crossword puzzles, then you'll love Flexicon, a game which combines four overlapping crossword puzzles into one! http://g.msn.ca/ca55/208 |