필터 지우기
필터 지우기

calllib crashes Matlab... no error given

조회 수: 13 (최근 30일)
tlawren
tlawren 2011년 10월 14일
댓글: rubina mahtab 2016년 12월 7일
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];
???
  댓글 수: 15
tlawren
tlawren 2011년 10월 17일
@Philip - Is there a verion of Matlab that does support two dimensional arrays like mine? Does Matlab have documentation about not supporting two such arrays? If I didn't write the dll or the associated header file, is there a way for me to still use the dll?
tlawren
tlawren 2011년 10월 18일
Any advice or suggestions?

댓글을 달려면 로그인하십시오.

채택된 답변

tlawren
tlawren 2011년 11월 2일
I discovered the cause of my problem. The dll I am using requires a specific license and I didn't have that. The documentation provided by the creators of the dll's don't say anything about licensing, so it took some C code and phone calls to figure things out.
I should note that the Matlab errors/warnings I received seem to make no sense with respect to my license issue. Once I set my license files up correctly, everything ran seamlessly in Matlab!
  댓글 수: 1
rubina mahtab
rubina mahtab 2016년 12월 7일
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?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Philip Borghesani
Philip Borghesani 2011년 10월 17일
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.
This link gives one possible solution: 1-671ZZL
Another is to modify the c header file to properly state the calling convention and rebuild if needed.
  댓글 수: 3
tlawren
tlawren 2011년 10월 17일
The two warnings I've been seeing are one-in-the-same, at least I pretty sure they are. When I examined the prototype file that was generated by loadlibrary, I can see that 'int8#' is associated with the structure field gnFn. I'm guessing Matlab tries to parse char gnFn[10][1024], but doesn't know what to do with it so it just stops at 'int8#'. To be sure, if I remove the # symbol in the prototype file and then re-load the library, I don't get any warnings at all. This is wrong though, because the structure in the header still calls for a multi-dimensional array. Nonethelss, the calllib crash still occurs with this change, so it is likely not the cause of the crash, as you pointed out. Moreover, the function I'm trying to call in my dll doesn't even use this structure, so that also leads me to believe that it isn't behind the crash.
Could a third calling convention other than cdecl and stdcall be used in my dll?
Philip Borghesani
Philip Borghesani 2011년 10월 19일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 C Shared Library Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by