Why does MATLAB crash when I make a function call on a DLL in MATLAB 7.6 (R2008a)?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 8 Sep. 2011
Bearbeitet: MathWorks Support Team
am 6 Dez. 2013
When I try to use a DLL in MATLAB 7.6 (R2008a) it crashes. I get a very short stack trace. It does work with MATLAB 7.5 (R2007b) though.
Akzeptierte Antwort
MathWorks Support Team
am 8 Apr. 2015
This could be an issue related to how the DLL exposes it methods. It is possible that MATLAB does not understand the calling convention for the specific function contained within the DLL. The function may be using the STDCALLcalling convention resulting in a MATLAB crash. This error can be detected in several ways:
-- Nearly empty stack trace
-- C mex file would have required fixed header or special compile options to work.
-- It worked in previous versions of MATLAB
To solve the issue, create a PROTOTYPE file for the library and edit it with the correct fcns.calltype values.
1. Create the prototype file, 'mHeader':
[notfound, warnings] = loadlibrary('library.dll', 'library.h', 'mfilename', 'mHeader');
2. Unload the library:
unloadlibrary('library')
3. Edit the prototype file, mHeader.m. Change all instances of 'cdecl' to 'stdcall'
4. Load the library using the prototype file:
[notfound, warnings] = loadlibrary('library.dll',@mHeader);
This command loads the DLL with the correct calling convention.
Note: The above mentioned change is needed in MATLAB 7.6 (R2008a) and later versions. The issue is not present in MATLAB 7.5 (R2007b) and earlier versions.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!