views:

191

answers:

1

Platform: Windows 7, 64 bit (x64), Visual Studio 2008

I chose Python & Swig binding as the scripting environment of the application.

As a prototype, created a simple VS solution with main() which initializes Python (Py_Initalize, Py_setPyHome, etc) & executes test.py. In the same solution created another project which is a DLL of a simple class. Used SWIG to wrap this class. This DLL is the _MyClasses.pyd. test.py creates the objects of my class & calls its member functions.

All this works like a charm in the Release mode. But does not work in Debug mode (even tried banging my head on the laptop ;-) ).

Output of my work looks like this (in both release & debug):

  x64
    -debug
     - _MyClasses.pyd
     - MyClasses.py
     - test.exe
     - test.py
     - python26.dll
     - python26_d.dll

Note that the debug version is linked against python26_d.lib. Had to build python myself for this!

test.py
import MyClasses

print "ello"
m = MyClasses.Male("John Doe", 25)
print m.getType()

Male is the C++ class.

The problem:
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    import MyClasses
  File "...\x64\Debug\MyClasses.py", line 25, in <module>
    _MyClasses = swig_import_helper()
  File "...\x64\Debug\MyClasses.py", line 17, in swig_imp
ort_helper
    import _MyClasses
ImportError: No module named _MyClasses
[15454 refs]

I am used to Makefiles & am new to Visual Studio. I dont know who the culprit is here: Swig, The debug build of Python, Visual Studio, my stupidity.

Thank you in advance. It will be a great help.

A: 

Alright - found it. The debug output dll has to be named xxx_d.pyd!! In above case it would be _MyClasses_d.pyd

sambha