// factorial.i
%module factorial
%{
extern int fact(int n);
%}
#define VERSION 0.1
extern int fact(int n);
// factorial.cpp
int fact(int n) {
if (n <= 1) {
return 1;
}
return n * fact(n - 1);
}
$ swig -c++ -python factorial.i
$ g++ -fPIC -c factorial.cpp factorial_wrap.cxx -I/usr/include/python3.4
$ g++ -shared factorial.o factorial_wrap.o -o _factorial.so