using calllib for 32 bit native module built in Microsoft Visual C++ 2008.

3 Ansichten (letzte 30 Tage)
Hi,
I am working on a program that will call functions from a dynamic link library that was written in Microsoft Visual C++ 2008 and compiled in Microsoft Visual Studio 2008 as a 32 bit native module. Should I anticipate trouble using loadlib and calllib to access these functions on a 64 bit version of Matlab running on Windows 7? Will the 32 bit vs. 64 bit issue be a problem? Does loadlib and calllib work for C++ dll?
Thanks, Shennan

Akzeptierte Antwort

James Tursa
James Tursa am 30 Mai 2014
You can't mix 32-bit s/w and 64-bit s/w. You will not be able to call functions from a 32-bit dll from within a 64-bit application. You either need to recompile the lib as a 64-bit lib, or use a 32-bit version of MATLAB.
  4 Kommentare
Shennan Weiss
Shennan Weiss am 31 Mai 2014
I am showing my ignorance. Do you mean that I will only need to use extern C on the exported functions described in the header file for the dll?
Thanks Shennan
James Tursa
James Tursa am 31 Mai 2014
Bearbeitet: James Tursa am 31 Mai 2014
Yes. You can use C++ code all you want in the mex function, but the exported function signatures must be C. The function itself can use C++ code in the body, but its signature must be extern C for the interface in order to be able to use calllib on it. That, of course, means the dll must be compiled this way ... it is not sufficient to have a header h file for calllib to use with extern C if the dll was not compiled that way in the first place (since no such functions by that name would exist in the dll because of name mangling).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Call C from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by