Building extensions with MinGW on Win2K - formerly "Extension module import error with MinGW, SWIG, and distutils"
pschmidt at omnimn.com
Tue Aug 13 22:15:13 CEST 2002
I finally got things working, at least, without SWIG, which is ok for
now. Baby steps!
Surprisingly, a colleague of mine did not have to go through the
gyrations I did. He simply downloaded MinGW, and was able to create
extensions right away. One difference is that he does not have Cygwin
installed, and I do, so it could be that I was accidentally using some
of the Cygwin tools, instead of the MinGW tools. (This is something I
should investigate further...)
Anyway, here's a summary of what I had to do to be able to build
Python extensions on a Win2K machine using MinGW.
1) Download (from http://prdownloads.sourceforge.net/mingw/MinGW-1.1.tar.gz?download)
and install MinGW. I put MinGW in c:\Mingw.
2) Download Paul Sokolovsky's altbinutils-pe 1_0 zipfile. Unzip it,
and put the contents of the \bin directory into your MinGW\bin
directory. This gets pexports.exe, which you need to create the .def
file for python22.dll. See
3) Create the import library libpython22.a. You can do this manually,
or use the script described by Mike Fletcher
To do it manually, type the following two commands. Be sure that your
path points to the MinGW\bin directory, so that pexports and dlltool
run from there. (Change the Python path in the commands to match your
pexports c:\winnt\system32\python22.dll >
dlltool -d C:\PROGRA~1\PYTHON22\libs\python22.def -l
4) Run distutils to build the module.
More information about the Python-list