|
From: Barry S. <ba...@ba...> - 2008-08-02 13:00:09
|
In the vcproj file for example I have the following:
<Tool
Name="VCLinkerTool"
AdditionalOptions="/export:initexample"
Make sure you are also have this /export:initcinterpreter in your
vcproj file.
Barry
On Aug 1, 2008, at 08:13, <hap...@ho...>
<hap...@ho...> wrote:
> 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 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(); }
>
>
>
>
> ----------------------------------------------------------------------
> ---
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> CXX-Users mailing list
> CXX...@li...
> https://lists.sourceforge.net/lists/listinfo/cxx-users
|