First page Back Continue Last page Overview Graphics

Compiling for Dynamic Loading

gcc -fPIC -c -I/usr/include/python2.7 -I/usr/lib/python2.7/config factorial.c wrapper.c

gcc -shared factorial.o wrapper.o -o factorial.so

Importing Module in Python:

>>> import factorial

>>> factorial.fact(10)

3628800

>>> factorial.fact(6)

720

>>>

If a module is called

example the so file

has to be called

example.so or

examplemodule.so!