Problem compiling a GUI
1 view (last 30 days)
Show older comments
Hi everyone,
I'm trying creat a a Windows standalone application of a simple GUI with the deploytool. I got generate the executable, but when I try open it I receive the following message in the prompt window:
"??? Undefined function or variable 'file_name'. MATLAB : UndefinedFunction"
I'm using the MATLAB 2008a (7.6.0). What's the problem?
0 Comments
Answers (4)
Fangjun Jiang
on 27 Nov 2011
What do you mean by "when I try open it"? If you've got an executable (*.exe file), you should run it in Windows Command Window, not in MATLAB Command Window.
5 Comments
Image Analyst
on 27 Nov 2011
No, mfilename is. Please post the entire contents of your startup code, at least until you see the first reference to file_name. If you used GUIDE, this would be the OpenFcn() function.
Image Analyst
on 27 Nov 2011
You never assigned a value to file_name by the time it executed that line of code. Try making your code more robust by using constructs like try/catch, isempty(), exist(), and so on. When you're making an executable for other users to run, that is no time to get loose and sloppy with your code. In my executables, every single function has try/catch and I always construct full filenames with fullfile(), check for existence, create folders if necessary, validating values, validating user inputs, etc. A substantial number of lines in my code, maybe 10%-30%, is spent idiotproofing the code for unexpected things. Sounds like you have little or none of that. It saves you time to cut out all the bulletproofing but will get you in the end because the unexpected will always happen sooner or later.
try
fullFileName = fullfile(pwd, 'myFile.dat');
% Make sure the file exists.
if ~exist(fullFileName)
errorMessage = sprintf('Error in function blah_blah_blah\nFile does not exist:\n%s', fullFileName);
% Show in console window.
fprintf('%s\n', errorMessage);
% Pop up dialog box also
uiwait(warndlg(errorMessage));
return;
end
% File was found - continue with your other code.
catch ME
% Gets here for a general exception.
errorMessage = sprintf('Error in function blah_blah_blah.\n\nError Message:\n%s', ME.message);
% Show in console window.
fprintf('%s\n', errorMessage);
% Pop up dialog box also
uiwait(warndlg(errorMessage));
end
0 Comments
Peter Ferreira
on 20 Dec 2011
3 Comments
Fangjun Jiang
on 20 Dec 2011
It might be this one.
http://www.mathworks.com/support/bugreports/436507
Image Analyst
on 20 Dec 2011
Peter, what was the name of the folder you installed your "file_name.exe" app to? Was it really long? When you run your exe, that's not actually running the exe and it unpacks a ton of stuff (including the *real* actual executable) into the folder defined by MCR_CACHE_ROOT. I usually set mine to . (dot) so that it unpacks all that stuff into subfolders of my app's folder instead of some weird hidden folder deep within c:\documents and settings\username\local setting\blah\blah\blah. You can put the line "ctfroot" in your startup code to have it print the folder in the command window when it starts (if it starts).
Wilson
on 20 Mar 2013
Edited: Wilson
on 20 Mar 2013
Hi everyone
I received this error when i tried to executed Multitest_1.exe
Multitest_1_OpeningFcn (line 67)
daq.createSession requires a vendor ID. Use 'daq.getVendors()' for a list of
vendors.
I the Multitest_1.m i did
id = get(daq.getVendors(),'ID') obj = daq.createSession(id)
And in the matlab, the program run very well.
Any idea what is the problem with the compiler?
matlab version R2012b
thanks
wilson
1 Comment
Image Analyst
on 20 Mar 2013
Please start your own discussion for this rather than posting your question as an "Answer" to a 16 month old question from someone else.
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!