calling dll from MATLAB / making header file

2 次查看(过去 30 天)
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

采纳的回答

Friedrich
Friedrich 2014-4-3
编辑:Friedrich 2014-4-3
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 个评论
Krzysztof Fajst
Krzysztof Fajst 2014-4-3
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 2014-4-3
编辑:Friedrich 2014-4-3
I would try
double __stdcall dzBuy(double* sourceArray[],double probabiltyValue, int lookBack, int bars, int i );

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by