Why does MATLAB Compiler issue a warning regarding "startup.m" adding paths?
26 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 23 de Oct. de 2017
Comentada: Stefanie Schwarz
el 31 de Ag. de 2024
Why does creating a standalone application with MATLAB Compiler generate the following warning regarding "startup.m" adding paths?
ERROR: Warning: Your deployed application may fail 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.
In older versions of MATLAB, the error message is:
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.
Respuesta aceptada
MathWorks Support Team
el 31 de Ag. de 2024
Editada: MathWorks Support Team
el 22 de Feb. de 2024
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
2 comentarios
Bruno Luong
el 6 de Jul. de 2022
"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
Más respuestas (1)
Bruno Luong
el 6 de Jul. de 2022
Editada: Bruno Luong
el 6 de Jul. de 2022
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.
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!