Why does MATLAB Compiler issue a warning regarding "startup.m" adding paths?

조회 수: 68 (최근 30일)
Why does creating a standalone application in MATLAB R2017a or later generate the folllowing warning regarding "startup.m" adding paths?
ERROR: Warning: Your deployed application may error out because file or folder paths
not present in the deployed environment may be included in your MATLAB startup
file. Use the MATLAB function "isdeployed" in your MATLAB startup file to
determine the appropriate execution environment when including file and folder
paths, and recompile your application.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2024년 2월 22일
편집: MathWorks Support Team 2024년 2월 22일
The warning message was introduced in R2017a and is intended to let the users know that having a user-defined startup script for MATLAB ("startup.m" ) may cause errors in the deployment environment, since "startup.m" files will be compiled into the application. It also recommends using the "isdeployed" function to determine the current execution environment.
Note that getting this warning does not necessarily mean that the "startup.m" file(s) have any code that is changing or adding paths. The warning is emitted if any "startup.m" is present on the MATLAB path, or in any path that contains files that the packaged application depends on.
Make sure to inspect the "startup.m" files present in your MATLAB installation:
>> which startup.m -all
Determine whether the content present in the "startup.m" files is relevant to your compiled application. The recommended structure for startup.m files is the following:
% startup.m file
if ~isdeployed
% statements under this block will execute at startup
% when you run MATLAB on your desktop
else
% statements under this block will execute at startup
% when MATLAB compiled application is run on a deployed machine
end
% add statements outside the if-else block if you would like to execute them on both your desktop and deployed machines
One example of useful startup code that could be added to a deployed application is to turn off warnings for all deployed applications:
if isdeployed
warning off
end
  댓글 수: 1
Bruno Luong
Bruno Luong 2022년 7월 6일
"When you add files using the -a flag ...As a result, the dependency analyzer is able to find 'startup.m' file and hence gives the warning message."
Sorry it doesn' make much sense to me. Why it is matter the dependency analyzer find startup and user added file that migh have nothing to do with startup?
This warning is too sensitive and unjustified, and thus anoying

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

추가 답변 (1개)

Bruno Luong
Bruno Luong 2022년 7월 6일
편집: Bruno Luong 2022년 7월 6일
Turn off the warning
warning('off','Compiler:compiler:COM_WARN_STARTUP_FILE_INCLUDED')
You might put it in your startup.m so that this anoying warning does appear anymore.
Don't delete you startup.m it's there for a reason.
It's just me but I think the startup should never be included in the compilation, at least we must have a switch option NOT to include it during the compilation.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by