开发者

Compiled MATLAB: Why does my application hang at the end?

I'm using MATLAB's deployment tool to compile a simple project which uses a mex library. The executable runs OK and does what it's supposed to do except that when it's supposed to finish, nothing happens. It just sits there.

When I'm compiling any other project, for instance the magic square example from the docs, it works OK. The executable finishes and exits.

I added a disp('at end'); at the end of the .m file, and this line is indeed getting displayed so I know it got to the end of the .m file but it just doesn't exit the process.

Why does this happen?


Edit:

In MATLAB it runs normally, returning after the 'at end'. The code is way too long to include here. It does fairly normal stuff, other than using the mex lib开发者_JAVA技巧rary.


There's not a lot of details to go by in the question, but here are two possibilities:

  1. There are visible figure windows at the end of execution. A compiled application will wait for all figure windows to terminate before exiting. See MATLAB Compiler documentation for the function mclWaitForFiguresToDie.

  2. Somehow the MEX library is calling the built-in function waitforcallbacks, which will "prevent the application from exiting until waitforcallbacks(false) is called." Also note (from the help for waitforcallbacks): "Calls to waitforcallbacks nest. waitforcallbacks(false) must be called the same number of times waitforcallbacks(true) has been called for a deployed application to exit."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜