I am trying to use a library available on the web http://www.metarecognition.com/libmr-license/ via python. The authors have provided C code and swig interface file (*.i). The Make file provided by the users does not provide correct python compiling. So I tried to manually compile swig. I am using following commands after compiling the main library.
swig -python weibull.i
gcc -c ../libMR/weibull.c weibull_wrap.c -I/usr/include/python2.4 -fPIC
ld -shared weibull.o weibull_wrap.o -o _weibull.so
These steps work fine. But when I try to import it via python, I am getting following errors:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "pyweibullw.py", line 29, in <module>
_pyweibullw = swig_import_helper()
File "pyweibullw.py", line 21, in swig_import_helper
import _pyweibullw
ImportError: /usr/lib/python2.4/dist-packages/_pyweibullw.so: undefined symbol: Py_InitModule4
Can somebody please tell me whats wrong? Am I making missing some flags for gcc? I have tried gcc with flags like -m64, --arch x86_64 but it doesnt seem to make any difference. FYI, I am using following system
bash-$:uname -a
Linux 2.6.32-5-amd64 #1 SMP Mon Oct 3 03:59:20 UTC 2011 x86_64 GNU/Linux