Partially Attended

an irregularly updated blog by Ian Mulvany

wrapping c code for python using swig on Mac OS X

Wed Jan 21, 2009

62 Words
from john d cook


and combining the two I came up with a way to get this to work on Mac OS X

bash$ cat erf.i

%module erf
double erf(double);

bash$ swig -o erf_wrap.c -python erf.i
bash$ gcc -o erf_wrap.os -c -fPIC -I/usr/include/python2.4 erf_wrap.c
bash$ gcc -o -shared erf_wrap.os
bash$ python
>>> from erf import erf
>>> erf(1)
This work is licensed under a Creative Commons Attribution 4.0 International License