comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: External c calls broken in IDL 5.5
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: External c calls broken in IDL 5.5 [message #32006 is a reply to message #32000] Wed, 04 September 2002 04:22 Go to previous messageGo to previous message
Nigel Wade is currently offline  Nigel Wade
Messages: 286
Registered: March 1998
Senior Member
Bob wrote:

> I have some dlm's that I made using DLMFORM (see
> http://www.astro.uio.no/~steinhh/idl/dlmform.html). They call fortran
> code through a c wrapper. They worked fine on IDL 5.3 and Tru64 Unix
> 5.0 but now that I've upgraded to IDL 5.5 and Tru64 Unix 5.1A they will
> no longer work (they core dump). I've tried remaking them and that
> doesn't help. Has anyone else had this problem?
>
> So I've tried a really simple example (below) using call_external and
> just using c code and even the simple code that follows doesn't work
> (it should print out "n = 25" and "x = 3.14159"). Anyone have any
> ideas.
>
> And last, is there a newer version of dlmform. I really like this
> routine but it is using some obsolete functions.
>
> Thanks,
> Bob
>
> In test.c
> #include <stdio.h>
> #include "export.h"
>
> void test(int argc, IDL_VPTR argv[])
> {
> IDL_LONG n = argv[0]->value.l;
> printf("n = %i\n", n);
> float x = argv[1]->value.f;
> printf("x = %f\n", x);
> }
>
> I complile and link with:
> cc -c -I/usr/local/rsi/idl/external -pthread test.c
> ld -S -expect_unresolved '*' -shared -all -hidden -o test.so test.o
>
> then trying it:
> $ idl
> IDL Version 5.5, Compaq Tru64 (OSF alpha). (c) 2001, Research Systems,
> Inc.
> IDL> n = 25l
> IDL> x=!PI
> IDL> help,n,x
> N LONG = 25
> X FLOAT = 3.14159
> IDL> dum = call_external('./test.so', 'test',n,x)
> n = 1074012760
> x = 0.000000
> IDL>

The interface you have specified is for a DLM/LINKIMAGE function, but you
have tried to call it with call_external (which has a completely different
execution method).

Try instead:

IDL> linkimage,'test','./test.so',0,'test'
IDL> test,n,x


--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL Primer
Next Topic: Re: CW_Animate procedure...

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:32:51 PDT 2025

Total time taken to generate the page: 0.00435 seconds