App Designer: App runs from Matlab but not after Compiler

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

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.
Unfortunately there is no such log file.
I run the app out of the 'for testing' folder which should create a log file. It seems there is no other way to create/display errors is it?!
Mario Malic
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.
Ah this looks helpful. I create the app right now. Let's see what the error is.
Okay I got the error.
In the function I was calling from Startup Function I called a lot of other functions. In one function I'm reading a xls-file whos name get's passed from the Startup Function to the ConfigFunction. Somehow App Designer is able to read a xls-file without the ending .xls. Compiler seems not be able to do so. This was the problem. I have to add the ending .xls to the name and everything is working fine.
Your tip about the log-file option was very helpful! Thanks a lot!
Cool! You're welcome.
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.
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
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.
Alright, makes some sense. Thank you very much.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.

Preguntada:

el 12 de Oct. de 2020

Editada:

el 12 de Oct. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by