calling dll from MATLAB / making header file

2 visualizaciones (últimos 30 días)
Krzysztof Fajst
Krzysztof Fajst el 3 de Abr. de 2014
Editada: Friedrich el 3 de Abr. de 2014
Hello,
I'm trying to load dll to MATLAB but unfortunatelly I dont have original header file for it. On the other hand I know that in another C like language this dll is imported like this
#import "dynamicZone.dll"
double dzBuy(double& sourceArray[],double probabiltyValue, int lookBack, int bars, int i );
double dzSell(double& sourceArray[],double probabiltyValue, int lookBack, int bars, int i );
#import
so I created my header file like this
#ifndef dynamicZone
#define dynamicZone
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* Functions and data types defined... */
double __stdcall dzBuy(double * sourceArray[],double * probabiltyValue, int * lookBack, int * bars, int * i );
double __stdcall dzSell(double * sourceArray[],double * probabiltyValue, int * lookBack, int * bars, int * i );
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
but when I try to load it I get 'dynamicZone.dll is not a valid Win32 application'. Is it maybe that I used * in double& sourceArray[] ??
Any idea ??
Krzysztof

Respuesta aceptada

Friedrich
Friedrich el 3 de Abr. de 2014
Editada: Friedrich el 3 de Abr. de 2014
Hi,
the error "not a valid Win32 application" indicates a bittedness missmatch. Either the DLL is a 32bit DLL and you try to load it into a 64bit MATLAB or the DLL is 64bit and you try to load it into a 32bit MATLAB. This will not work. You have to make sure that the bittedness of MATLAB and the DLL is the same.
In addition your created header file is wrong, e.g . probabiltyValue is passsed in as value and not as reference.
  2 comentarios
Krzysztof Fajst
Krzysztof Fajst el 3 de Abr. de 2014
yes that true my matlab is 64 bit, I was hoping it will be OK.
Regarding header. What would be a correct syntax ?? I tried
double __stdcall dzBuy(double& sourceArray[] but getting
error C2143: syntax error : missing '{' before '&'
Friedrich
Friedrich el 3 de Abr. de 2014
Editada: Friedrich el 3 de Abr. de 2014
I would try
double __stdcall dzBuy(double* sourceArray[],double probabiltyValue, int lookBack, int bars, int i );

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by