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

Re: IDL and DLL under windows

I think, 'undefined symbol' means, that IDL can't find the routine in the
DLL. Routines in a DLL must be exported. You can do this with a .def file or
with eg following entry in the header file:
#ifndef IDL_RETURN
 #define IDL_RETURN __declspec(dllexport)

IDL_RETURN int function_name(int argc, void *argv[]);

The parameters are always passed by reference, so the DLL can change them.

I added example.h and example.c. Build a DLL with them and try this with

temp = fltarr[5]
number = 5
out = 1.1  ; this is because out must also be a float!!

result = call_external('example.dll','sumarray',temp, number, out)

In out should now be the correct sum of the array.


Dominik Paul
Universitätsklinikum Freiburg
Abt. PET/Nuklearmedizin

"StefanoM" <massetti@tiscalinet.it> schrieb im Newsbeitrag
> sorry for this long post.
> well, I would like to use my Fortran subroutine with IDL.
> To do this I have created a DLL whit MS Develop. Studio and then called
> subroutines from IDL with CALL_EXTERNAL. The problem is that ... it
> work!!! This could be related to the way the parameters are passed to the
> soubroutines, by value or by reference. If I simply compile and link the
> subroutines 'as they are' into a DLL, then it is impossible to call them
> from IDL, otherwise, if I follow the example given with IDL (5.2):
>        SUBROUTINE SUM_ARRAY(argc, argv)  !Called by IDL
>        INTEGER*4 argc, argv(*)                             !Argc and Argv
> are integers
>        j = LOC(argc)
> !Obtains the number of arguments (argc)
> !Because argc is passed by VALUE.
> c Call subroutine SUM_ARRAY1, converting the IDL parameters
> c to standard FORTRAN, passed by reference arguments:
>        CALL SUM_ARRAY1(%VAL(argv(1)), %VAL(argv(2)), %VAL(argv(3)))
>        RETURN
>        END
> c This subroutine is called by SUM_ARRAY and has no
> c IDL specific code.
> c
>        SUBROUTINE SUM_ARRAY1(array, n, sum)
>        INTEGER*4 n
>        REAL*4 array(n), sum
>        sum=0.0
>        DO i=1,n
>        sum = sum + array(i)
>        ENDDO
>        RETURN
>        END
> I get errors during the linking of the DLL, in particular: 'undefined
> symbol' related to the subroutine (SUM_ARRAY1) called from the 'interface'
> subroutine (i.e. SUM_ARAY that manages the passage of the parameters from
> IDL to DLL).
> Does anyone have experience about this ? Any suggestion ?
> Stefano
> stefano.massetti@katamail.com

begin 666 example.h

begin 666 example.c
M;G0@87)G8RP@=F]I9" J87)G=EM=*0T*>PT*:6YT(&X[#0IF;&]A="!S+"IF
M+" J<W5M.PT*#0IF(#T@*&9L;V%T("HI(&%R9W9;,%T[#0IN(#T@*BAI;G0@
M*BD@87)G=ELQ73L-"G-U;2 ]("AF;&]A=" J*2!A<F=V6S)=.PT*#0IF;W(@
H*',@/3 N,#L@;BTM.RD@<RL]("IF*RL[#0HJ<W5M(#T@<SL-"@T*?0``