libpython20.a for building extensions using mingw32

Robert Kern kern at caltech.edu
Tue Oct 17 06:40:14 CEST 2000


In article <8sep0l$6g5$1 at nnrp1.deja.com>, Hamish Lawson
<hamish_lawson at yahoo.co.uk> wrote:

> I'm trying to use Robert Kern's py-mingw32 approach
> (http://starship.python.net/crew/kernr/mingw32/Notes.html) to build an
> extension using mingw32, but for Python 2.0 rather than Python 1.5.2.
> Instead of libpython15.a I'm guessing I would need a libpython20.a.
> Where would I get that or how would I build it?

I don't have a platform to test any of this on or look at the files 
themselves, but ...

If the Python 2.0 Windows binary distribution is anything like 1.5.2's, 
then there will be a "libs" subdirectory in the main Python directory.
There will be a file "libs/python20.lib" or something similar. In the
file http://starship.python.net/crew/kernr/mingw32/Py-mingw32-tools.zip ,
there is a script lib2def.py that will extract the symbol names from 
python20.lib and create a DEF file. It calls the program nm.exe which comes
with your mingw32 distro.

Then use dlltool.exe (also from mingw32) to create the libpython20.a . The 
exact call is in the Makefile in the archive mentioned above. If you have
GNU make and a python interpreter in your PATH, then you can just edit
the Makefile to reflect the new version, move it into the libs subdirectory, 
and run "make all".

One problem you might run into is that lib2def.py won't catch all of the 
symbols. I wrote lib2def.py as a hack that worked for 1.5.2, and some 
important symbols in 2.0 may be left out. Give it a shot, and use the bare
output of "nm -Cs python20.lib" to see if you've missed anything.

Good luck.  I'd like to hear from you if you succeed.

> Hamish Lawson

-- 
Robert Kern
kern at caltech.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."



More information about the Python-list mailing list