[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: R: AAARGH!!! IDL5.2 crashes with CALL_EXTERNAL



Stefano,

I think you missed my point.  EXTPROC_DEFINE will not work with
IDL 5.2  You must be running IDL 5.3 or higher for it to work.
If you are using the idl_tools.dll from Ronn's web site, it was
compiled for the IDL 5.3 entry points and will crash IDL if used
with 5.2.  If you recompile the DLL yourself for IDL 5.2, you 
will find that EXTPROC_DEFINE will return (-1) for your example.

From the comment in the source code for idl_defproc.c:

/* at present only under Windows and IDL 5.3 and higher */
#if defined(WIN32) && ((IDL_VERSION_MAJOR > 5) || ((IDL_VERSION_MAJOR ==
5) && (IDL_VERSION_MINOR >= 3)))

If compiled under IDL 5.2, the functions are defined as:

IDL_VPTR IDL_CDECL extproc_define(int argc, IDL_VPTR argv[], char *argk)
{
	return(IDL_GettmpLong(-1));
}

IDL_VPTR IDL_CDECL extproc_query(int argc, IDL_VPTR argv[], char *argk)
{
	return(IDL_GettmpLong(-1));
}

So a properly compiled idl_tools.dll will always return (-1) under
IDL 5.2.

Now, I am running Win98 myself and IDL 5.3.1 and I run:

IDL Version 5.3.1 (Win32 x86). (c) 2000, Research Systems, Inc.

IDL> print, EXTPROC_DEFINE("mysin","msvcrt.dll","sin","d(d)",/cdecl)
% Loaded DLM: IDL_TOOLS.
           0
IDL> print,mysin(0)
      0.00000000
IDL> print,mysin(!PI*0.5)
       1.0000000

This approach works very nicely for FORTRAN DLLs (lots of interesting
libraries out there, e.g. FFTW) and things like VTK for example. 

I cannot comment on your problems with CALL_EXTERNAL as I have
insufficient information, but the crash you are getting w/idl_tools.dlm
is due to the fact that you are mixing DLLs compiled for different
versions of IDL (which cannot be done reliably).  Your idl_tools.dll
was compiled for IDL 5.3 and running it under IDL 5.2 is expected to
cause a crash.  If you want to use EXTPROC_DEFINE, you will need to
upgrade to at least IDL 5.3.1. If you are using IDL 5.4, you will need 
to recompile the DLM yourself (all the sources/project files are there).

Hope it helps.

StefanoM wrote:
> 
> My PC is running WIN98 II (second edition) and the C and Fortran compiler
> are that of Microsoft Develop Studio 4.0.
> The problem seems to be not related to the compilers, since (as I wrote) I
> get problems even calling a routine in a system library,
> in fact I follow the example suggested by Ronn Kling to explain the DLM
> utility "idl_tools.dlm":
> 
> print, EXTPROC_DEFINE("mysin","msvcrt.dll","sin","d(d)",/cdecl)
> 
> that should assign the function "sin" of the library "msvcrt.dll" to the IDL
> function "mysin", the function should take a single argument as double and
> return a double ... "d(d)". When I type the above command IDL seems to
> accept the definition of the new function "mysin", but then when I try to
> use "mysin" IDL crashes (idlde causes errors in IDL32.DLL and MFC42.DLL).
> The same result is obtained compiling the SUM_ARRAY examples in the IDL
> distrubution ...
> 
> There are a lot of useful Fortran libraries in the web, it is really sad
> that I cannot use them with IDL !!!
> 
> have a nice day
> 
> Stefano
> 
> Mark Rivers <rivers@cars.uchicago.edu> wrote in message
> kU5G6.354$E4.22251@uchinews...
> >
> > StefanoM wrote in message <9c9hqv$hbe$1@canarie.caspur.it>...
> > >AAARGH!!! IDL 5.2 crashes every time I try to call a DLL subroutine with
> > >CALL_EXTERNAL.
> ....
> ....
> ....
> > Tell us a little more.  What platform are you running on, what compiler,
> > etc.?
> >
> > I certainly have used IDL 5.2 with CALL_EXTERNAL with no problems.
> >
> > Mark

-- 
rjf.
Randy Frank                            | ASCI Visualization
Lawrence Livermore National Laboratory | rjfrank@llnl.gov
B451 Room 2039  L-561                  | Voice: (925) 423-9399
Livermore, CA 94550                    | Fax:   (925) 423-8704