Function Pointer Example not working
Subject: Function Pointer Example not working
Newsgroups: gmane.comp.programming.swig
Date: 2008-11-14 21:57:56 GMT
Hi All,
Yesterday I posted about the question I had of template function. This time I worked step step from examples in Doc 1.3 to reach my ultimate goal. But as I worked on the Function Pointer Example in 5.4.9 in Doc 1.3, it doesn't work. My platform is a Ubuntu linux with swig 1.3.36, python 2.5.2 and gcc 4.2.3.
The compiling and linking has no errors:
swig -python -c++ -o test_wrap.cpp test.i
python setup-test.py build
running build
running build_py
copying test.py -> build/lib.linux-i686-2.5
running build_ext
building '_test' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c test_wrap.cpp -o build/temp.linux-i686-2.5/test_wrap.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-i686-2.5/test_wrap.o build/temp.linux-i686-2.5/test.o -o build/lib.linux-i686-2.5/_test.so
But when I try to import test in python, it complains:
import _test
ImportError: ./_test.so undefined symbol: _Z9binary_opiiPFiiiE
My test.i is:
%module test
%{
#include "test.h"
%}
%include "test.h"
%callback("%s_cb");
int add( int, int ); //add_cb
int sub( int, int ); //sub_cb
int mul( int, int ); //mul_cb
%nocallback;
My test.h is:
int binary_op(int a, int b, int (*op)(int,int) );
int add( int a, int b ) { return a+b; }
int sub( int a, int b ) { return a-b; }
int mul( int a, int b ) { return a*b; }
// NOTE: this is func ptr from example in Doc 1.3: 5.4.9
It is really strange to me. I am a novice swigger but I really need its power to accelerate my development. Could anybody point out where my problem is?
TIA
Charlie
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Swig-user mailing list Swig-user <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/swig-user
RSS Feed