Here we shall use a binary search tree c program and invoke the same from python
The c function file : download here , name it as bst.c
The swig interface file : download here , name it as bst.i
The make file would be : saved as mf
all:bst.o bst_wrap.o
ld -shared bst.o bst_wrap.o -o _bst.so
python p.py
bst_wrap.c:bst.i
swig -python bst.i
bst.o:bst.c
gcc -c bst.c -o bst.o -I/usr/include/python2.6
bst_wrap.o:bst_wrap.c
gcc -c bst_wrap.c -o bst_wrap.o -I/usr/include/python2.6
kindly note that the path to python directory and the version may be different for you .
The python p.py file :
import bst
bst.bst()
Execute the make file as > make -f mf
But with the make file:
<A tutorial and explanation for all stuff's mentioned here will be provided asap>
The c function file : download here , name it as bst.c
The swig interface file : download here , name it as bst.i
The make file would be : saved as mf
all:bst.o bst_wrap.o
ld -shared bst.o bst_wrap.o -o _bst.so
python p.py
bst_wrap.c:bst.i
swig -python bst.i
bst.o:bst.c
gcc -c bst.c -o bst.o -I/usr/include/python2.6
bst_wrap.o:bst_wrap.c
gcc -c bst_wrap.c -o bst_wrap.o -I/usr/include/python2.6
kindly note that the path to python directory and the version may be different for you .
The python p.py file :
import bst
bst.bst()
Execute the make file as > make -f mf
But with the make file:
<A tutorial and explanation for all stuff's mentioned here will be provided asap>
Thhis was a lovely blog post
ReplyDelete