SWIG: name 'new_doubleArray' is not defined

A

alexandre_irrthum

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;
}
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:
But this fails: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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top