Python extensions using MinGW and CXX
Gerhard Häring
gerhard.haering at opus-gmbh.net
Fri Feb 14 05:12:54 EST 2003
Reinhard Nadrchal <reinhard at proceryon.at> wrote:
> To create the python import library I did the following (with my
> specific paths provided):
>
> pexports /C/WINDOWS/system32/python20.dll > python20.def
> dlltool --dllname /C/WINDOWS/system32/python20.dll --def python20.def
> --output-lib libpython20.a
> and copied libpython20.a to the Python20/libs directory.
Try not to use any paths for python20.dll. I. e.:
$ pexports python20.dll >python20.def
$ dlltool --dllname python20.dll --def python20.def --output-lib libpython20.a
You'll need to have copied python20.dll in your working directory first.
I remember another user had weird problems when he used absolute paths and
the above method worked for him.
> If I, on the other hand, link in python20.dll I get no errors and ld
> seems to be happy. The trouble starts when I execute 'import foo' from
> the python interpreter - it simply crashes without any comment.
>
> g++ -shared -lpython20 foo.o -ofoo.pyd
>
> That's the way I've tried it so far. I've also tried to link without the
> -shared option using -mdll,
Python's distutils uses -mdll, but I really don't know the meaning of
either one in the win32 context :-(
> but in this case Python doesn't recognize
> the 'initfoo' entry point - maybe this is the key ?! Ho do I have to
> declare/define the init function ???
With DL_EXPORT:
#v+
extern "C" {
DL_EXPORT(void) initfoo() {
// ...
}
}
#v-
-- Gerhard
More information about the Python-list
mailing list