Problem compiling a GUI
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (4개)
Fangjun Jiang
2011년 11월 27일
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
Image Analyst
2011년 11월 27일
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
2011년 11월 27일
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
Peter Ferreira
2011년 12월 20일
댓글 수: 3
Image Analyst
2011년 12월 20일
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
2013년 3월 20일
편집: Wilson
2013년 3월 20일
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
Image Analyst
2013년 3월 20일
Please start your own discussion for this rather than posting your question as an "Answer" to a 16 month old question from someone else.
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!