Python debug libraries

Bryan belred1 at yahoo.com
Wed Oct 29 02:14:54 EST 2003


Mike C. Fletcher wrote:

> See my recent post...
> 
> http://groups.google.ca/groups?q=debug+extension+win32+group:comp.lang.python&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mailman.26.1065949224.2192.python-list%40python.org&rnum=2 
> 
> 
> (all one line).  You probably don't want to debug *everything*, just 
> your particular extension, and this recipe allows that fairly readily 
> w/out requiring getting every single dependency built against debug 
> Python (which can be a royal PITA).
> 
> HTH,
> Mike
> 
> Robert Ferrell wrote:
> 
>> I'm trying to do some debugging of python extensions on Windows2K.  MS
>> Visual Studio (.NET) says it can't find the debug version of the
>> python libraries.  (The message is "python.exe does not contain any
>> debugging information".)  I installed the binaries from the Windows
>> installer.  How should I get the debug libraries?  Or is that even
>> what I need?  I'm kind of new to Windows, and Visual Studio in
>> particular, so maybe I'm way off base.
>>
>> thanks,
>> -robert
>>  
>>
> _______________________________________
>  Mike C. Fletcher
>  Designer, VR Plumber, Coder
>  http://members.rogers.com/mcfletch/
> 
> 
> 
> 

in our company, we do not link to debug third party libraries.  i'm embedding python (using visual studio) and run into 
the same problem.  we now resort to undef'ing _DEBUG before including the python header files and everything works 
correctly.  if you look in the python header files, you will see that when _DEBUG is defined, there is a #pragma to link 
to pythonXX_d.lib.  when _DEBUG is not defined it will link to pythonXX.lib.  other's may disagree about this approach, 
but so far it works well and we don't have any memory problems at all.

for extensions using distutils here's another option which i prefer, since you can do this on a case-by-case basis 
instead of modifiying msvccompiler.py:

add this line to setup in your setup.py file:

extra_compile_args = ['/Od /Z7'],
extra_link_args = ['/DEBUG'],

since these options will be placed after the compile/link options that distutils uses, these options will be used, 
overriding the options in msvccompiler.py.

bryan






More information about the Python-list mailing list