[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: IDL and DLL under windows
- Subject: Re: IDL and DLL under windows
- From: "Dominik" <dpaul(at)ukl.uni-freiburg.de>
- Date: Tue, 10 Apr 2001 12:57:29 +0200
- Newsgroups: comp.lang.idl-pvwave
- Organization: Rechenzentrum der Universitaet Freiburg, Germany
- References: <9auh62$o6p$1@suite03.caspur.it>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:24479
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)
#endif
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
IDL:
temp = fltarr[5]
temp[0]=1.1
temp[1]=2.1
temp[2]=3.1
temp[3]=4.1
temp[4]=5.1
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
_____________________________
Dominik Paul
dpaul@ukl.uni-freiburg.de
Universitätsklinikum Freiburg
Abt. PET/Nuklearmedizin
"StefanoM" <massetti@tiscalinet.it> schrieb im Newsbeitrag
news:9auh62$o6p$1@suite03.caspur.it...
> 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
the
> subroutines from IDL with CALL_EXTERNAL. The problem is that ... it
doesn't
> 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
M(VEF;F1E9B!)1$Q?4D5455).#0H@(V1E9FEN92!)1$Q?4D5455).(%]?9&5C
M;'-P96,H9&QL97AP;W)T*0T*(V5N9&EF#0H-"DE$3%]215154DX@<W5M87)R
=87DH:6YT(&%R9V,L('9O:60@*F%R9W9;72D[#0H`
`
end
begin 666 example.c
M(VEN8VQU9&4@(F5X86UP;&4N:"(-"@T*241,7U)%5%523B!S=6UA<G)A>2AI
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``
`
end