I have written a very very simple program in Visual C++ 2008 SP1. It just adds up two numbers. The DLLTest.cpp is:
#include "DllTest.h"
__declspec(dllexport) double Add(double a, double b)
{
return( a + b );
}
And DllTest.h is:
#ifndef _DLL_TEST_H_
#define _DLL_TEST_H_
#endif
__declspec(dllexport) double Add( double, double);
I build the DLL using Visual C++ 2008. When I try to load the library using loadlibrary
, I get the following error:
??? Error using ==> loadlibrary at 422 Building DllTest_thunk_pcwin64 failed. Compiler output is: DllTest_thunk_pcwin64.c C:\Users\Admin\Desktop\DllTest.h(5) : error C2054: expected '(' to follow 'EXPORTED_FUNCTION' C:\Users\Admin\Desktop\DllTest.h(5) : error C2085: 'Add' : not in formal parameter list DllTest_thunk_pcwin64.c(40) : error C2085: 'int8' : not in formal parameter list DllTest_thunk_pcwin64.c(41) : error C2085: 'uint8' : not in formal parameter list DllTest_thunk_pcwin64.c(42) : error C2085: 'int16' : not in formal parameter list DllTest_thunk_pcwin64.c(43) : error C2085: 'uint16' : not in formal parameter list DllTest_thunk_pcwin64.c(44) : error C2085: 'int32' : not in formal parameter list DllTest_thunk_pcwin64.c(45) : error C2085: 'uint32' : not in formal parameter list DllTest_thunk_pcwin64.c(46) : error C2085: 'int64' : not in formal parameter list DllTest_thunk_pcwin64.c(47) : error C2085: 'uint64' : not in formal parameter list DllTest_thunk_pcwin64.c(48) : error C2085: 'voidPtr' : not in formal parameter list DllTest_thunk_pcwin64.c(49) : error C2085: 'string' : not in formal parameter list DllTest_thunk_pcwin64.c(51) : error C2082: redefinition of formal parameter 'EXPORTED_FUNCTION' DllTest_thunk_pcwin64.c(51) : error C2143: syntax error : missing ';' before 'type' DllTest_thunk_pcwin64.c(52) : error C2085: 'EXPORTED_FUNCTIONdoubledoubledoubleThunk' : not in formal parameter list DllTest_thunk_pcwin64.c(52) : error C2143: syntax error : missing ';' before '{'
I want just to load a simple program, written in Visual C++, in MATLAB. How can I fix this problem?