Integrating Python with C++

SWIG supports C++
The only difference is when we run SWIG (-c++ option):
swig -python -c++ -I.. hw.i
# generates wrapper code in hw_wrap.cxx
Use a C++ compiler to compile and link:
root=`python -c 'import sys; print sys.prefix'`
ver=`python -c 'import sys; print sys.version[:3]'`
g++ -O -I.. -I$root/include/python$ver \
    -c ../hw.cpp hw_wrap.cxx
g++ -shared -o _hw.so hw.o hw_wrap.o

previousnexttable of contents