|
From: Barry S. <ba...@ba...> - 2008-08-06 22:18:32
|
On Aug 3, 2008, at 17:59, <hap...@ho...>
<hap...@ho...> wrote:
> I am using Python 2.5 and VC++ 9.0.
What the product called? VC++ 9.0 isn't Microsoft name is it?
>
> It works for the release version.
Sounds like the options for Debug are missing something important
that is in Release options.
>
> I improved what I was doing and attempted with the debug version,
> but I get "ImportError: No module named example_d". My
> improvements are that I compiled Python 2.5 using VC++ 9.0 and ran
> the debug version of Python interpreter, then I tried "import
> example_d".
>
Python adds _d to the name of file to load is you compile python with
Py_DEBUG defined.
You also have to compile your extension with Py_DEBUG defined.
This is because the C API changes when Py_DEBUG is defined.
Personally I compile python Debug but not with Py_DEBUG defined.
If you do want to run with Py_DEBUG defined then your extension must
define
initexample_d in a file called example_d.pyd.
Use python -v to see teh details of the files attempted to be loaded
when you say import.
Barry
>
> From: ba...@ba...
> Subject: Re: Unable to init function during import of debug version
> of extension
> Date: Sun, 3 Aug 2008 13:59:40 +0100
> To: cxx...@li...
>
>
> On Aug 2, 2008, at 22:17, <hap...@ho...> wrote:
>
> Yes, even though you have "/export:initexample" in the vcproj file
> for the provided example, the problem is still there when importing
> the compiled DEBUG version of module in the python interpreter.
> I'll state again what that problem is:
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: dynamic module does not define init function
> (initexample)
>
> Which version of python are you using?
> Which compiler are you using to build the example?
>
> Does it work for Release version?
>
> When Python is compiled for debug it changes the name of the entry
> point to initexample_d. Since
> that is not being asked for I guess you have a Release build of
> python.
>
> try python -vv to see the path used to find the example.pyd file.
> Make sure that it is importing
> the one you are building.
>
> Barry
>
>
>
>
>
>
>
> From: ba...@ba...
> Subject: Re: Unable to init function during import of debug version
> of extension
> Date: Sat, 2 Aug 2008 13:59:41 +0100
> To: cxx...@li...
>
> 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
>
>
> ----------------------------------------------------------------------
> ---
> 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
>
>
> ----------------------------------------------------------------------
> ---
> 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
|