Posts

Showing posts with the label wrapper

Swig Tutorial example Mac Os Lion

This tutorial is based on Leopard Tutorial but still works, thou some warnings. First, we create an example.c file with this content: /* File : example.c */ #include <time.h> double My_variable = 10.0; int fact(int n) { if (n Second, we create the interface between C and Python with the following file: /* example.i */ %module example %{ /* Put header files here or function declarations like below */ extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); %} extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); Now that we have all the source files we need, we compile them in this way: $ swig -python example.i $ cc -c `python-config --cflags` example.c example_wrap.c $ cc -bundle `python-config --ldflags` example.o example_wrap.o -o _example.so if you have problems with this step check this other post So, everything looks nice, but how do we use ...