call_external segmentation fault [message #55306] |
Wed, 15 August 2007 17:36 |
sc.bugger
Messages: 2 Registered: August 2007
|
Junior Member |
|
|
Are there some pitfalls in using 'call_external' of C libraries which
were created by different gcc versions?
I have exactly the same code working on the one computer (linux x86
m32, gcc 3.4.5) and crashing on the other one (linux x86, m32, gcc
4.2.1). What can be the problem?
I use "gcc -fPIC -c mypro.c && ld -shared -o libmypro.so mypro.o"
Here is the code, nothing especially:
-------------- mypro.c ----------------
#include <stdio.h>
#include <math.h>
#include "/opt/idl/external/include/idl_export.h"
int wsum(int argc, void *argv[])
{
float *coeff, *xmax, *out, *xvalue;
IDL_MEMINT *nc, *nx, i,j;
wights = (float *) argv[0];
nc = (IDL_MEMINT *) argv[1];
nx = (IDL_MEMINT *) argv[2];
xmax = (float *) argv[3];
out = (float *) argv[4];
for (i=0; i<*nx; i++)
{
*xvalue = -*xmax + 2. * *xmax * i/(*nx-1);
*(out + i) = 0.;
for (j=0; j<*nc; j++)
*(out + i) += pow(*xvalue,j+1) * *(wights + j);
}
return 1;
}
----------------- mytest.pro --------------------
function mytest, wights, nx, xmax, out
return, call_external('libmypro.so','wsum',$
wights, $
n_elements(coeffs), $
nx, $
xmax, $
out, /f_value)
end
Thank you for any hint.
Vlad
|
|
|