Extension with MinGW

Andrew Gregory andrew.gregory at npl.co.uk
Mon Dec 9 05:38:45 EST 2002


anton at vredegoor.doge.nl (Anton Vredegoor) wrote in message news:<aso936$9o2$1 at news.hccnet.nl>...
> Borland does something with the underscores. The .def file can be used
> to remove this. I notice that your filenames have underscores too, are
> you mixing two kinds of black magic? :-) Did you use exactly this .def
> file for Borland *and* Mingw? If not I'd like to see the Borland .def.
> If yes I'd like to see the wrapper. 
> 

Mystery solved (thanks to Gerhard Haring):

To create libpython22.a I used
c:\dev-cpp\bin\dlltool --dllname C:\python22.dll --def python22.def
--output-lib libpython22.a

but should have copied python22.dll to the current working directory
and used
c:\dev-cpp\bin\dlltool --dllname python22.dll --def python22.def
--output-lib libpython22.a

It's as simple (and frustrating) as that!
----------------------------------------
Now about underscores:

In the wrapper file created by SWIG 1.3.14 and later find:

#define SWIG_init    init_pysimple

#define SWIG_name    "_pysimple"

The compiled DLL must be called _pysimple.pyd or _pysimple.dll
otherwise
get a python error on importing. Earlier versions of SWIG do not
generate these underscores - see Python section of latest SWIG manual.

"distutils" seems to generate the .def file automatically to suit the
compiler. But if compiling without "distutils" need _pysimple.def as
follows:

for MinGW (--compiler=mingw32):

LIBRARY _pysimple.pyd
EXPORTS
init_pysimple

and for Borland Builder (--compiler=bcpp):

LIBRARY _pysimple.pyd
EXPORTS
  init_pysimple=_init_pysimple


Regards,

Andrew.



More information about the Python-list mailing list