Re: Problems when calling functions from a .dll
- From: "Philip Borghesani" <philip_borghesani@xxxxxxxxxxxxxx>
- Date: Wed, 7 Dec 2005 11:44:33 -0500
I have two guesses given the limited information you have supplied.
1. The function return value should probably just be double not double*
2. Your functions are probably stdcall (frequently called WINAPI) so try
adding __stdcall to the function:
double __stdcall FunctionNameInTheDll (double* , double*);
Phil
"Ingo Leusbrock" <Ingo.Leusbrock@xxxxxx> wrote in message
news:ef1dd13.-1@xxxxxxxxxxxxxxxxxxx
> Hello everyone!
>
> I have quite some problems with calling functions from a .dll. I
> assume that this is more or less due to my rather small knowledge
> when it comes to the structure of dll's and working with FORTRAN and
> not because the problem is so complicated (I am an engineer, no
> computer scientist ;-) ).
> The situation is as this:
> I have a .dll-file; originally written in Fortran and compiled by
> Compaq Visual Fortran Compiler. The .lib is also available, but the
> source code is missing since the .dll is part of a commercial
> software package. The original purpose of this package was to import
> the .dll to Excel with a .xla-file as an Add-In (this works fine so
> far). All functions, input and output values are defined as DOUBLE
> PRECISION (double in Matlab); the arguments are transfered BY
> REFERENCE and the values of the functions are given back BY VALUE.
> My idea was now to import the .dll to Matlab. Since the header file
> is missing, I used the function declaration used in the .xla-file
> /code
> Declare Function xyz Lib "mydll.DLL" (ByRef x As Double, ByRef y As
> Double) As Double
> /codeoff
>
> as a basic for my header file, which is based on the example file
> delivered by Matlab (shrlibsample.h):
> /code
>
> #ifndef myheader_h
> #define myheader_h
>
> /* Function declarations */
> EXPORTED_FUNCTION double* FunctionNameInTheDll (double* , double*)
> ;
>
> #endif
>
> /codeoff
>
> (There are several functions in the .dll, some have just one double
> as input. But that is not the problem.)
> So far so good. From this point on my problems start. When I now try
> to call the function via 'calllib('myDLL','myFunction', Pointer1,
> Pointer2)' I get a matlab crash. What I already tried was to work
> without pointers and to use the syntax of the examples in the
> shrlibsample.c . More or less with no sucess.
> As a solution I have thought of sending my matlab variables to Excel,
> let the .dll do its work there and send the data back to Matlab. But
> this is no real situation, more a workaround and I do not know, how
> this will influence the calculation time if I have to send/receive
> the data to Excel rather often (esp. when I have to do iterations).
>
> So, if anyone can give me some advice, it would be very muc h
> appreciated.
>
> P.S.: Another solution might be to call the .dll in Fortran and then
> send the data to Matlab, since the .dll was originally was written in
> Fortran. I assume that there might be less problems there, but I am
> rather clueless when it comes to Fortran/working with MEX-Files.
.
- Follow-Ups:
- Re: Problems when calling functions from a .dll
- From: Ingo Leusbrock
- Re: Problems when calling functions from a .dll
- References:
- Problems when calling functions from a .dll
- From: Ingo Leusbrock
- Problems when calling functions from a .dll
- Prev by Date: Using matrix identification numbers
- Next by Date: Re: matlab's max arithm. representation??
- Previous by thread: Problems when calling functions from a .dll
- Next by thread: Re: Problems when calling functions from a .dll
- Index(es):
Relevant Pages
|