loading modules in debug

A

Andras Balogh

The project I'm working on is written mainly C/C++, spiced with some
Python scripts. Now, I have several dlls, which work both as a Python
extension modules, exporting functions to Python via "initmodule", and
as normal dynamic libraries, to which I link dynamically from within my
C program.

The problem is that, in debug mode, Python expects every module name to
be postfixed with _d, which makes my dynamic loading (using LoadLibrary)
not work, unless I #ifdef it everywhere, and append _d to the dlls
myself. I could do this, but I don't really like the idea. I'd be happy
to use the release python interpreter in debug mode too, but the python
header automatically pulls in the debug version.

Any ideas/suggestions what could I do?

thanks,


Andras
 
G

greg.landrum

[I haven't seen an answer for this older question, so I figured I'd go
ahead and post one]

Andras said:
The problem is that, in debug mode, Python expects every module name to
be postfixed with _d, which makes my dynamic loading (using LoadLibrary)
not work, unless I #ifdef it everywhere, and append _d to the dlls
myself. I could do this, but I don't really like the idea. I'd be happy
to use the release python interpreter in debug mode too, but the python
header automatically pulls in the debug version.

Any ideas/suggestions what could I do?

The easiest way to avoid this behavior on Windows is to replace the
code where you #include <Python.h> with something like this:

#ifdef _DEBUG
#undef _DEBUG
#include <Python.h>
#define _DEBUG
#else
#include <Python.h>
#endif

This should cause Python to stop looking for the _d named dlls.

-greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top