SWIG: name 'new_doubleArray' is not defined
alexandre_irrthum at yahoo.com
alexandre_irrthum at yahoo.com
Wed May 17 09:10:24 EDT 2006
Hello,
I am trying to use SWIG (1.3) to wrap some C code in Python (2.3.5)
under Linux, but obviously I am missing something with arrays.
This is my example.c file:
double sum_array(double x[], int size) {
int i;
double sum = 0.0;
for (i=0; i<size; i++) {
sum += x[i];
}
return sum;
}
This is example.i:
%module example
%include "carrays.i"
%array_functions(double, doubleArray);
%{
extern double sum_array(double x[], int size);
%}
extern double sum_array(double x[], int size);
These three command seem to work fine:
swig -python example.i
gcc -fPIC -c example.c example_wrap.c -I/usr/include/python2.3
ld -shared example.o example_wrap.o -o _example.so
In python, I can import the module:
>>> import example
But this fails:
>>> a = new_doubleArray(10)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'new_doubleArray' is not defined
What am I doing wrong ?
Thanks for your help.
alex
More information about the Python-list
mailing list