Extension with MinGW
Gerhard Häring
gerhard.haering at gmx.de
Tue Dec 3 14:07:07 EST 2002
Andrew Gregory wrote:
> I've just tried compiling a Python extension using MinGW. Found
> import _pysimple
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> ImportError: DLL load failed: The specified module could not be found.
>
> Based on the instructions at
> http://starship.python.net/crew/kernr/mingw32/Notes.html
>
> I compiled /linked using
> gcc -L"C:\Python22\include" -c pysimple_wrap.c -DBUILDING_DLL=1
>
> dllwrap --output-def lib_pysimple.def --implib lib_pysimple.a
> pysimple_wrap.o /
> -L"c:/python22/libs" -lpython22 --driver-name gcc -s --entry
> _DllMain at 12 /
> --target=i386-mingw32 --def _pysimple.def -o _pysimple.pyd
>
> File pysimple.h is
> extern int mysquare(int i)
> {
> return i*i;
> };
>
> pysimple_wrap.c is created using SWIG 1.3.16
>
> File _pysimple.def is
> LIBRARY _pysimple.pyd
> EXPORTS
> init_pysimple
>
>
> I didn't load any patches (used gcc 3.2). It works ok with Borland
> 5.5.
> Any ideas?
Thanks to the PSU's time machine, I answered your question before you asked it:
http://groups.google.com/groups?q=group:comp.lang.python+mingw32+distutils+gerhard&hl=en&lr=&ie=UTF-8&selm=mailman.1004731924.4764.python-list%40python.org&rnum=2
Shorter URL:
http://tinyurl.com/36xy
Your setup.py file might look like this:
#v+
from distutils.core import setup, Extension
setup (name = "pa",
version = "1.0",
maintainer = "Alex Martelli",
maintainer_email = "aleax at aleax.it",
description = "Sample Python multimodule package",
ext_modules = [Extension('pa',sources=['pa.c'])]
)
#v-
-- Gerhard
More information about the Python-list
mailing list