MATLAB: Loadlibrary problem with DLL file

dllloadlibraryMATLABmex

When I try to call loadlibrary in MATLAB on a particular DLL file (using 64bit R2013a in Windows 7), I get a big list of errors like these:
error C2143:
syntax error : missing ')' before '*'
error C2143:
syntax error : missing ')' before '='
The errors refer to all lines in the DLL's header file that have or optional inputs like:
Int32 NCB_API PositionerCheck( PositionerInfo** posInfo );
or
Int32 NCB_API PositionerMoveAbsolute( Int32 deviceHandle, Int32 axisNo, Int32 position, Int32 rotCount = 0 );
I wrote a short C++ mex function that uses LoadLibrary() (the C++ function) to load the DLL and call its functions. My mex function compiles without problems with Microsoft Visual C++ 2012 and can successfully call the DLL functions.
The company that produced the DLL also supplies a 32bit version. With the 32bit version, I can compile and use my mex function , and I can also call loadlibrary in MATLAB and use the DLL that way. The header file for the 32bit version is identical to the 64bit one.
So far, I have only found one solution page ( http://www.mathworks.com/support/solutions/en/data/1-HNFE5H/index.html?solution=1-HNFE5H ) that seems relevant. I tried adding
#define __fastcall
to the header file, but the errors were unchanged.
Is there anything else I can try to get loadlibrary to work? The errors seem pretty generic, so I am not sure what to do to debug the problem. The DLL is supplied by a third party, so I do not have access to its contents to check if it contains an error, but since the mex function works with the DLL and the company's 32bit DLL works okay, it does not seem like the DLL is the problem.
SEBASTIAN: Your private message had no contact information, so I have no way to respond to you directly. The only changes I made to attocube's code was to modify hvpositionerinfov2.h as Friedrich suggested. For MATLAB to communicate with the ANC350, you also need to have the ANC350 driver installed, the .dll (and maybe .lib) file needs to be on the Windows path and on the MATLAB path. Then you can use loadlibrary('hvpositionerv2.dll','hvpositionerv2.h') to load the library and calllib('hvpositionerv2',…) to access the ANC350 API. If you need more help, send another private message with some form of contact information. I hope this helps. I can send you my notes and MATLAB functions if you want them.

Best Answer

Hi,
loadlibrary is for native C only. So if your header file contains C++ statements it won't work. Make sure your header file is C compatible.
In the case it doesn't help, upload your header files and DLL's and post the link. Also state how you call loadlibrary in MATLAB.