App Designer: App runs from Matlab but not after Compiler
Mostrar comentarios más antiguos
Hi everyone,
I have an app created in App Designer. If I run it directly from Matlab/App Designer everything works perfect. But after I used Matlab Compiler the app doesn't work anymore. In my startup function I call this function
app.Config = ConfigFunction(app);
to load the startup values set on the GUI to app.Config (which is a private property). This seems to create an error after Compiler is used. I have set a couple of message-boxes to figure out where the error occurs.
But why is everything working fine befor compilation and after compilation the .exe doesn't work?
10 comentarios
Mario Malic
el 12 de Oct. de 2020
There should be a log file somewhere in the directory, in it should be written the output of the command window. Write the error. I am also interested in this as well.
Dominik Müller
el 12 de Oct. de 2020
Mario Malic
el 12 de Oct. de 2020
Editada: Mario Malic
el 12 de Oct. de 2020
When you open the MATLAB Compiler, click on Settings, and you'll see a question mark icon next to the 'Additional parameters passed to mcc:', click on it and there might be some options that might be helpful.
There is a way, but I do not remember at the moment, how to do it.
Edit: When packaging app, scroll down on the main window and see 'Additional runtime settings', two options there should help.
Dominik Müller
el 12 de Oct. de 2020
Dominik Müller
el 12 de Oct. de 2020
Mario Malic
el 12 de Oct. de 2020
Cool! You're welcome.
Bruno Luong
el 12 de Oct. de 2020
Most of the time the difference of paths of input files between deployed and matlab-integrated app does make a difference of behaviors.
One way to "debug" app is to launch it under command window. Under windows
left click "start menu" then "run" Type "cmd", o black command window open
Navigate to path of the deployed exe, then type the appname
cd "E:\...\Deployed"
E:
.\myApp.exe
If an error occurs, the error message stays there for you to see and might lead you to know what is the cause.
Mario Malic
el 12 de Oct. de 2020
I have a paths related question. In root of project I have an Application file, and other text files and functions. I copy these files to another folder and in that folder I make changes (copying is done within one helper function in App Designer).
How do I refer to the text file I would like to open that is packaged within the app? Everything works fine when I copy and paste files in the folder of .exe file.
Bruno Luong
el 12 de Oct. de 2020
Editada: Bruno Luong
el 12 de Oct. de 2020
I don't know, I never use Application Compiler app or compiler.package.installer. I use MCC command directly.
You need to make distinction how you open the text file, full path, relative path, etc... and use
isdeployed
function to determine which case the app is runing. I use this function to return the root path of the app, then read the file relative to the app root directory.
function currentDir = getcurrentdir
% currentDir = getcurrentdir
if isdeployed % Stand-alone mode.
[~, result] = system('set PATH');
currentDir = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
else % MATLAB mode.
thisfile = mfilename('fullpath');
currentDir = fileparts(fileparts(thisfile));
end
Of course you have to put the text file at the corresponding places.
Mario Malic
el 12 de Oct. de 2020
Alright, makes some sense. Thank you very much.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!