calllib crashes Matlab... no error given
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
tlawren
am 14 Okt. 2011
Bearbeitet: Chris
am 27 Nov. 2024 um 18:04
Greetings. I am trying to use some functions in a dll, but when I use calllib, Matlab crashes (and closes) without error.
Any idea what is going on?
EDIT: I just noticed that I got a warning(s) when I loaded the library.
Warning: Eval of const expression 10 ][ 1024 failed with error Unmatched right square bracket at (eval 5) line 1, at end of line syntax error at (eval 5) line 1, near "10 ]" Missing right curly or square bracket at (eval 5) line 2, at end of line
The offending line is...
char gnFn[10][1024];
???
16 Kommentare
Chris
am 27 Nov. 2024 um 17:59
Bearbeitet: Chris
am 27 Nov. 2024 um 18:04
While troubleshooting a similar issue, an option we did not have to pursue (solved the issue by using 2019a instead of MATLAB 2024a) was using a parallel process to run the DLL. If the DLL took a certain amount of time (in our case, 1-2 seconds was enough to know there was a problem), then the parallel process could be killed and move on. At least that was the principle. Maybe someone out there could make that a reality for their issue/workaround.
Another part of the problem was that initially my inputs exceded what the DLL could handle. So the DLL could perhaps have been coded better, but that part at least was my error.
See also
Akzeptierte Antwort
tlawren
am 2 Nov. 2011
1 Kommentar
rubina mahtab
am 7 Dez. 2016
I have the same issue as yours. But what I want matlab to do is to pop up a window saying license file missing, instead of crashing and without giving a proper error. I tried using try and catch but matlab still crashes. do you have any suggestion?
Weitere Antworten (1)
Philip Borghesani
am 17 Okt. 2011
The usual cause of a calllib call causing MATLAB to exit with no stack trace is the use of the wrong calling convention. loadlibrary defaults to cdecl but many 32 bit libraries are built with stdcall as the default calling convention.
Another is to modify the c header file to properly state the calling convention and rebuild if needed.
3 Kommentare
Philip Borghesani
am 19 Okt. 2011
Without more information is unlikely that we can help you. The amount of information needed probably belongs in a tech support call not this area.
Needed information
# Matlab version
# copy of header file
# copy of DLL
# full text/error output from your call to loadlibrary and any calllib calls.
Siehe auch
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!