call_external with auto_glue [message #58685] |
Wed, 13 February 2008 12:18 |
jingdaniel2007
Messages: 1 Registered: February 2008
|
Junior Member |
|
|
Hi,
I am learning to use call_external to call some C programs (from
slalib library) in idl. By checking the IDL help page, I found that
the keyword anto_glue can help generate the glue funtions to avoid the
argc-argv calling convention. This is helpful since I am not quite
familiar with C programming. But it didn't seem to work for me even
I tried on some simple routine like this one:
#include "slalib.h"
#include "slamac.h"
void slaCs2c ( float a, float b, float v[3] )
{
float cosb;
cosb = (float) cos ( b );
v[0] = (float) cos ( a ) * cosb;
v[1] = (float) sin ( a ) * cosb;
v[2] = (float) sin ( b );
}
I used get_callext_exlib.pro to build the sharable libary of external
C code and return the path as its result, which is from the examples
of call_external in idl (external/call_external/C) :
function get_callext_exlib
common GET_CALLEXT_EXLIB_BLK, shlib
....
source = 'cs2c'
export_rtns = 'slaCs2c'
MAKE_DLL, source, 'call_external_examples', export_rtns, $
INPUT_DIR=call_ex_dir, DLL_PATH=shlib
return, shlib
end
I am pretty sure get_callext_exlib and MAKE_DLL works since all the
examples of call_external in idl directory work for me. So I called
the C program in idl like this:
IDL> a=1. & b=2. & c=fltarr(3)
IDL> r=call_external(get_callext_exlib(),'slaCs2c',a,b,c,/auto_gl ue)
The commands ran without any problem, but I got all 0s for c. I am
very puzzled what could be wrong. I really appreciate if anyone can
help me. Thanks in advance !
|
|
|