extending python problem

Roger Hansen rogerha at ifi.uio.no
Sat Jun 24 05:58:25 EDT 2000


* rdejuana at my-deja.com
> 
> I'm trying to extend python with c.  I trying to
> get the progam at the tutorial to work. but every
> time i try to import it it tells me it cant find
> the init function.  This is the error:
> 
> >>>import libPYSTAF
> Traceback (innermost last):
>   File "./libPYSTAF.py", line 3, in ?
>     import libPYSTAF.so
> ImportError: dynamic module does not define init
> function (initlibPYSTAF)
> 
> This is my code:

[snip]

> I'm new to coding, so i probably forgot something
> stupid.  If you stop it please tell what it is.

Your code worked fine on my computers (Solaris and Linux). Are you
sure you compiled correctly? I did

:-) gcc -fpic -Wall -ansi -I/local/include/python1.5 -c pystaf.c 
:-) gcc -shared pystaf.o -o libPYSTAFmodule.so
:-) python -c 'import libPYSTAF'

The -fpic must be there, or else the code will be relocated when its
loaded. 

HTH,

R



More information about the Python-list mailing list