Matalb compiled App crash on plotting while code version runs correctly

24 ビュー (過去 30 日間)
Bertrand PINSARD
Bertrand PINSARD 2025 年 12 月 17 日 11:05
編集済み: dpb 2025 年 12 月 17 日 15:41
Hello,
I have an App which works well when running it from Matlab and I compiled it as a standalone application (it is intended to be delivered to a customer). But then the compiled App starts well (basically at opening it draws an Earth) and then i try to read a set of files with data and after some computation it is supposed to draw iso-contours (done by contourf) but instead it closes abruptally - no message in the log, no clue.
Any idea how to progress on that ?
Thanks in advance,
Bertrand

回答 (1 件)

dpb
dpb 2025 年 12 月 17 日 12:21
編集済み: dpb 2025 年 12 月 17 日 15:41
This can be a bear, indeed...
The first place to look is to be sure you can find any input files needed; figuring out where the installer puts them can be a real pain; where things are when compiled is not where they are when running directly. Look on the installed machine for any such files to be sure you know where they are.
I wrote the following logging routine and then instrumented the app extensively to report where it was and when if completed each function call. For debugging, compile with the option to open the console as well so it will be visible and then the error messages can be seen until close the app.
function displayprogress(app,varargin)
% writes function, line number to command line if debug on
if app.debugFlag
S=dbstack; % call stack struct
ix=find(matches(strip(string(strvcat(S(:).name))),'displayprogress'))+1; % find who called us
%out=sprintf('Function: %s Line: %d, %s',fncn,line,msg);
if nargin>1, msg=varargin(1); else msg=''; end
out=sprintf('Time: %7.4fs File: %s Name: %s Line: %d %s ',toc,S(ix).file,S(ix).name,S(ix).line,msg{:});
disp(out)
end
end
I added a menu item under an "Environment" menu in the app to be able to toggle the debug flag.
This turned out to be invaluable in tracking down a couple of elusive errors that I couldn't reproduce outside the compiled app.
  2 件のコメント
Bertrand PINSARD
Bertrand PINSARD 2025 年 12 月 17 日 14:44
Hello and thanks dbp
Regarding you can find any input files needed I actually put the .exe (Lets call it ZACApp.exe for clarity) at the same place as the code is. Don't know if that's a clue.
Also I forgot to mention that a previous version (quite similar) did work with r2023b.
I'll give a try to your routine - thanks for it - but I am not sure to know how to compile with the option to open the console - I guess a look at mcc help will help
Will report.
dpb
dpb 2025 年 12 月 17 日 15:38
"am not sure to know how to compile with the option to open the console"
If you build inside AppDesigner open the Additional Setting and there's a checkbox to not create the Windows Command Window that is checked by default. Uncheck it. I don't recall at the moment the actual switch...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by