Standalone application works in MATLAB but not outside

8 views (last 30 days)
I have an application that works perfectly in MATLAB but when compiled as a standalone application does not...
With a try and catch statement I think I discovered that the problem is the data file... I have a data file called Data.mat, I think that the standalone application is not able to find it. The function I am using to find the path for Data.mat is the following:
function thePath = showpath()
% Show EXE path:
if isdeployed % Stand-alone mode.
[status, result] = system('set PATH');
thePath = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
else % Running from MATLAB.
thePath=pwd;
end
The main program call this function in this way:
try
imgFile1 = fullfile(showpath, 'Data');
shipp=load(imgFile1);
catch err
if ~exist(imgFile1, 'file');
errordlg('File does not exist','Input Error');
else
rep = getReport(err, 'extended');
msgbox(rep)
end
end
Where is the mistake?

Accepted Answer

condor
condor on 11 Apr 2011
Answer FOUND:
The SYMS function is part of Symbolic Math Toolbox. You cannot compile any
functions from Symbolic Math Toolbox.
http://www.mathworks.com/products/compiler/compiler_support.html
http://www.mathworks.com/products/ineligible_programs/
--
Steve Lord
slord@mathworks.com
Is there any way to have my application compiled?

More Answers (7)

Robert Cumming
Robert Cumming on 11 Apr 2011
if your code isn't working that indicates your variable
thePath
is different when deployed and when not. Try printing it to the screen to check what it is. e.g something like:
function test
disp ( ['PWD=', pwd ] );
disp ( ['showPath=', showpath] )
end
function [thePath]=showpath()
% Show EXE path:
[status, result] = system('set PATH');
thePath = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
end
Check function both in Matlab and compiled.

condor
condor on 11 Apr 2011
I make a step backward, just to be sure....
When I compile (deploytool --> select my main file --> I click Build) the file "Data.mat" disapears, so once it is compiled I don't see it inside any folders (src and distrib ... what is the difference between these two folders?).
Is it still correct to load a file that I don't see? If there isn't any file...how can the software find it? If this is not correct how can I resolve it?

Robert Cumming
Robert Cumming on 11 Apr 2011
I've never used the deploytool - I still do everything from command line.
But having a look at it, have you added your Data.mat to the package, then after you build the exe you package it up - which will create a ZIP file or a self extracting exe which should contain your exe and data file...

condor
condor on 11 Apr 2011
I added the Data.mat on the deploytool GUI file but I don't see it...?! (Another thing, in the code I use symbolic object, is the toolbox symbolic math added automatically?)
These are the details that the copiler returns me:
ant:
<mkdir dir="C:\Users\quant\Desktop\Untitled1\distrib" />
<mkdir dir="C:\Users\quant\Desktop\Untitled1\src" />
mcc -o Untitled1 -W WinMain:Untitled1 -T link:exe -d C:\Users\quant\Desktop\Untitled1\src -w enable:specified_file_mismatch -w enable:repeated_file -w enable:switch_ignored -w enable:missing_lib_sentinel -w enable:demo_license -v C:\Users\quant\Documents\MATLAB\WorldTrade\ProgramWindow.m -a C:\Users\quant\Documents\MATLAB\WorldTrade\Data.mat -a C:\Users\quant\Documents\MATLAB\WorldTrade\fzine.m -a C:\Users\quant\Documents\MATLAB\WorldTrade\fzone.m -a C:\Users\quant\Documents\MATLAB\WorldTrade\ProgramWindow.fig -a C:\Users\quant\Documents\MATLAB\WorldTrade\showpath.m
Compiler version: 4.14 (R2010b)
Processing C:\Users\quant\Documents\MATLAB\WorldTrade\ProgramWindow.fig
Processing C:\Program Files\MATLAB\R2010b\toolbox\matlab\guide\guideopts.fig
Processing C:\Program Files\MATLAB\R2010b\toolbox\matlab\winfun\actxcontrolselect.fig
Processing C:\Program Files\MATLAB\R2010b\toolbox\matlab\winfun\actxcontrolcreateproperty.fig
Processing include files...
2 item(s) added.
Processing directories installed with MCR...
The file C:\Users\quant\Desktop\Untitled1\src\mccExcludedFiles.log contains a list of functions excluded from the CTF archive.
2 item(s) added.
Generating MATLAB path for the compiled application...
Created 42 path items.
Begin validation of MEX files: Mon Apr 11 19:07:27 2011
End validation of MEX files: Mon Apr 11 19:07:27 2011
Parsing file "C:\Users\quant\Documents\MATLAB\WorldTrade\ProgramWindow.m"
(Referenced from: "Compiler Command Line").
Parsing file "C:\Program Files\MATLAB\R2010b\toolbox\compiler\deploy\deployprint.m"
(Referenced from: "Compiler Command Line").
Parsing file "C:\Program Files\MATLAB\R2010b\toolbox\compiler\deploy\printdlg.m"
(Referenced from: "Compiler Command Line").
Deleting 0 temporary MEX authorization files.
Generating file "C:\Users\quant\Desktop\Untitled1\src\readme.txt".
copy 'C:\Users\quant\Desktop\Untitled1\src\readme.txt' 'C:\Users\quant\Desktop\Untitled1\distrib\readme.txt'
copy 'C:\Users\quant\Desktop\Untitled1\src\Untitled1.exe' 'C:\Users\quant\Desktop\Untitled1\distrib\Untitled1.exe'

condor
condor on 11 Apr 2011
When the software is compiled I only see 2 folders:
1) src:
  • mccExcludedFiles
  • readme
  • exe file
2) distrib
  • readme
  • exe file
I still not understand the difference between the two folders...
  2 Comments
Robert Cumming
Robert Cumming on 11 Apr 2011
src is the files generated by the compiler during compilation
distrib - is the files to be distributed.
condor
condor on 11 Apr 2011
which should I use when I test? Where should be the Data.mat?

Sign in to comment.


condor
condor on 11 Apr 2011
Changing the try and catch as the following:
try
imgFile1 = fullfile(showpath, 'Data.mat');
shipp=load(imgFile1);
catch err
%if ~exist(imgFile1, 'file');
%errordlg('File does not exist','Input Error');
%else
rep = getReport(err, 'extended');
msgbox(rep)
%end
end
I got the following (the name project is 'Untitled1'):
Error using load
Unable to read file C:\User\quant\Desktop\Untitled1\src\Data.mat: No such file or directory.
But as you can see above I added Data.mat...where am I mistaken?

condor
condor on 11 Apr 2011
@ Robert: I add it to the build and I don't see it... What do you mean if I see the file in the dir?
If I use:
mcc -mv ProgramWindow.m -a Data.mat
I get the following error:
??? Undefined function or method 'sym' for input arguments of type 'char'.
Error in ==> ProgramWindow>pushbutton1_Callback at 2223
Maybe this because I am not adding the symbolic toolbox?

Categories

Find more on Standalone Applications in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!