« Return to Thread: problems with python24_d.lib

Re: problems with python24_d.lib

by Bob Marinier :: Rate this Message:

Reply to Author | View in Thread

Sohail Somani wrote:
-----Original Message-----
From: swig-user-bounces@... 
[swig-user-bounces@...] On Behalf Of 
Bob Marinier
Sent: Wednesday, June 07, 2006 1:41 PM
To: swig-user@...
Subject: [Swig-user] problems with python24_d.lib

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
    

Could you do something like this for debug builds:

cl ... /U_DEBUG /D_REALLY_DEBUG lib_wrap.cc

In lib.i:

%module lib;
%{
#ifdef _REALLY_DEBUG
#	define _DEBUG
#endif
%}

Haven't tried it, but maybe it'll work
  
This seems to work great.  The only change I made was to use %runtime %{ ... %} to insert the code because that causes this to appear earlier in the generated code (otherwise is comes after "#include <stdexcept>", which may or may not matter).

Thanks!
Bob


_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

 « Return to Thread: problems with python24_d.lib