How To Compile Python Extensions On Windows/Cygwin

There are a lot of descriptions out there of how to do this, and most of them are outdated or just plain wrong. Here's what worked for me, yesterday. It assumes you've got Cygwin + gcc and the windows version of python 2.4, all installed into the default locations:

  1. Get pexport and extract it into a directory
  2. copy c:/Winnt/system32/python24.dll to the pexport directory
  3. run pexports python24.dll > python24.def
  4. run dlltool --dllname python24.dll --def python24.def --output-lib libpython24.a
  5. copy libpython24.a to c:\python24\libs\
  6. run c:\python24\python.exe setup.py build --compiler=mingw32
This worked well enough for me to build probstat successfully - I haven't tried it with anything else. I hope it helps, but if it doesn't work... as always, ask c.l.p.

UPDATE: To compile python extensions with python 2.5, check out this link.

Jul 28, 2006