C
Charlie
Hi All,
I am new to using swig/C++/python. I got some problem with function
pointers. I posted in swig-user, but got no response. So I forwarded
it here. You help is greatly appreciated.
Thanks!
---------- Forwarded message ----------
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
I am new to using swig/C++/python. I got some problem with function
pointers. I posted in swig-user, but got no response. So I forwarded
it here. You help is greatly appreciated.
Thanks!
---------- Forwarded message ----------
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