compiling extensions on linux

Martin v. Löwis loewis at informatik.hu-berlin.de
Mon Sep 2 12:31:26 EDT 2002


Joe Connellan <joec at mill.co.uk> writes:

> I'm trying to port an extension of mine from windows to linux and am not
> sure how to include the myExtension.def file in the compile 

You shouldn't have a .def file in the first place - I recommend that
you use distutils instead.

> eg if I use
> 
> g++ -shared -o myextension.so
> 
> it compiles fine but I get the following error when importing it into
> python
> 
> >>> import myextension
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ImportError: dynamic module does not define init function
> (initmyextension)

Nothing to this respect is needed on Linux. Are you sure your module
does define a initmyextension function?

It might be that it defines initmyextension__Fv instead, since you
compile your extension as a C++ program.

You should compile it as a C program, unless it really is a C++
program, in which case you need to define the init function as extern
"C".

HTH,
Martin



More information about the Python-list mailing list