calling dll from MATLAB / making header file

조회 수: 3 (최근 30일)
Krzysztof Fajst
Krzysztof Fajst 2014년 4월 3일
편집: Friedrich 2014년 4월 3일
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에서 Call C++ from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by