Compiled Matlab exe hangs when calling my Mex function

Hi, I have a Matlab GUI which uses a Mex file I created. Everything works fine when executing it in Matlab. I then created an exe file using deploytool, and the build process completes successfully, launching my GUI. However, when the code arrives at the first call to one of my mex functions, it just hangs there.
In order to check if my Mex code was causing the trouble, I recompiled the mex DLL with the whole mexfunction body commented out, so the mex function should just return after doing nothing. Even so, the compiled matlab exe hangs when calling this empty mex function.
Anyone knows what is causing the trouble?
And why is typing this message so difficult? The cursor pauses almost every character that I type ?

댓글 수: 1

The keyboard latency in this forum reduces the usability of the interface dramatically for some users, see http://www.mathworks.com/matlabcentral/answers/5560-do-you-suffer-from-keyboard-latency-in-this-forum . Please send another enhancement request to files@mathworks.com .

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

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2012년 6월 20일

0 개 추천

There is perhaps an error message that is causing the application to hang. Have you tried compiling your application without suppressing the command/shell window? Use the "Console Application" option instead of Windows standalone. When you run the thus compiled application, you should see a command window open in the background. See if there is any error displayed there?

댓글 수: 5

Hi there,
Thanks for replying. No, there is no error message. The first thing I did when trying to debug the problem was exactly that, creating a console application instead of a windows application. The thing is, I tried it on a Windows 7 computer with R2011b (64bit) on it, and it works there. I a working on a XP machine with R2010a and can't get it to work. Anyway. I lost too much time on this already. I'll move on and accept this as yet another bug.
You probably forgot to specify the full path of some file, for example in loadlibrary(). If you used just the base filename, it might not find it. Do you have any output to the screen that you can share? It's probably not a bug. Finally, check the FAQ for suggestions: http://matlab.wikia.com/wiki/FAQ#My_standalone_executable_won.27t_run_on_the_target_computer._What_can_I_try.3F
@Kyung Ho Park: I'm assuming that you have installed the MCR corresponding to R2011b on your XP machine (which I assume is also 64-bit)? You cannot run an application compiled using R2011b 64-bit against MATLAB libraries from a different version/platform. Or do you mean that the issue only occurs when you call into a MEX-file but not otherwise? Could you try running "which mexFunctionName" and print the result just before running the MEX-file? This will tell you if the issue might be that the compiled executable can't find the file in the first place.
Kyung Ho Park
Kyung Ho Park 2012년 7월 5일
편집: Kyung Ho Park 2012년 7월 5일
Hi. I finally got everything to work. I'm a little bit embarrassed to say that it were all my mistakes. At first, in my C++ code used by mex, I failed to disable all parts related to the Matlab engine. This must be done, because compiled applications can not use the engine, of course. So, I added a new build configuration in Visual C++ that defines a preprocessor macro that disables these code sections and includes. My second mistake was then that in this new build configuration, I renamed the output name from xxx.mexw32 file to xxx_deployed.mexw32, to have both versions in same directory. Of course, I forgot that the Matlab code was looking for the xxx file... So I moved the _deployed version to another dir, renamed it back to xxx.mexw32 and included it back in the deploytool, et voila, it worked, as one would expect. My apologies for "bugging" you with this... & thank you for your help!
Glad you worked that out. Thanks for posting your solution!

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

카테고리

도움말 센터File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

질문:

2012년 6월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by