Using SWIG to build C++ extension

mk mrkafk at gmail.com
Sun Jul 13 12:41:50 CEST 2008


Hello Bas,

Thanks, man! Your recipe worked on Debian system, though not on RedHat, 
and I still have no idea why. :-) Anyway, I have it working. Thanks again.


> I took your example files and did the following:
> changed the #include "edit_distance.h" to #include "edit_distance.c"
> in the edit_distance.i file. 
> Then I changed the first few lines of your function definition
> unsigned int edit_distance( const char* c1, const char* c2 )
>   {
>     std::string s1( c1), s2( c2);
> and also adapted the signature in the edit_distance.i file.
> Then
> swig -shadow -c++ -python edit_distance.i
> g++ -c -fpic  -I/usr/include/python edit_distance_wrap.cxx
> g++ -shared edit_distance_wrap.o -o _edit_distance.so




More information about the Python-list mailing list