Am Wed, 07 Jun 2006 22:40:37 +0200 hat Bob Marinier
<
rmarinie@...> geschrieben:
> Hi,
>
> I'm wrapping some code for Python on Windows using Visual Studio 2005
> (although I think this will all be exactly the same in 6 and 2003).
>
> When I'm doing a debug build, the symbol _DEBUG is defined (and it needs
> to be defined). Something in Python.h, then, tells the linker it needs
> python24_d.lib. The problem is that the Windows installer for Python
> does not include this file. One possible workaround I found on the
> Python mailing list is to change the SWIG output so that
>
> #include "Python.h"
>
> becomes:
>
> #ifdef _DEBUG
> #undef _DEBUG
> #include "Python.h"
> #define _DEBUG
> #else
> #include "Python.h"
> #endif
>
> This "tricks" Python.h into thinking this is not a debug build, and thus
> is looks for python24.lib instead, which does exist. This works, and
> since I'm not trying to debug Python, I don't care that I'm not linking
> the debug library. But having to manually change SWIG's output each
> time I generate it is a real pain. Is there either a way to change
> SWIG's output to this or does anyone have another idea for how to
> workaround this problem? And no, renaming python24.lib to
> python24_d.lib does not work :) (they aren't binary compatible).
I had lots of trouble with this either and use the version you pointed
out. Actually, it stopped working with VS 2005 because VS threw an error
when it noticed that some header files were compiled with _DEBUG defined
and some without. So for 2005 I had to fix a header in the python
installation myself and commented out every #define Py_DEBUG (or similar,
don't remember exactly). I agree that this solution is really nasty, but
couldn't find a better way (except compiling the python24_d.lib from
python source which I don't want to do).
Our build system (SCons) fixes those files automatically and replaces the
#include "python.h" with the code you showed above every time the wrapper
is regenerated, so this is not much hassle for us anymore. Just under 2005
we have to change that nasty python header which is really evil.
Imo this is python's fault though. It shouldn't have those #pragma
comment(lib, python24_d.lib) in its header. I should tell the program what
to link to, not the python headers.
If you find a better solution, please post here!
-Matthias
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user