Runtime errors in compiled standalone

Hi! I'm trying to figure out why my compiled standalone app, whose source runs fine within Matlab, is crashing. First I was getting the "File not found" error, despite the fact that the file it couldn't find is in the very same directory as the "main" file. So I went ahead and explicitly included the file in the project; that got me past that File not found error, but the log file my program generates indicates theat the program kept throwing an "Unable to checkout a license for" error...when it gets to one of my files! (Though the path it gave for it--it's the same file each time, a classdef m file that gets called inside a loop--seems somewhat suspect: it's finding it under C:\Users\dgol461\AppData\Local\Temp\dgol461\mcrCache7.16\Proces16\). And when it gets to my closing "clean-up" routine, it again crashes w/ the File not found error, again despite the presence of the unfound file in the same directory as the main.
Please help; thanks!

1 Kommentar

David Goldsmith
David Goldsmith am 16 Jan. 2013
Bearbeitet: David Goldsmith am 16 Jan. 2013
I may have found the answer; I just sent the following email to my MathWorks support rep:
"I note from the thread http://www.mathworks.com/matlabcentral/newsreader/view_thread/287203 that '[one has] to use the same version of the MCR as the version of MATLAB Compiler [one] used to compile the executable.' Now, in my MATLAB Compiler Runtime directory, I have a single folder named v716, which I interpret to mean that I have version 7.16 of the MCR installed. However, the output of my ver command is:
{ >> ver -------------------------------------------------------------------------------------
MATLAB Version 7.13.0.564 (R2011b)
MATLAB License Number: redacted
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1) Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ Client VM mixed mode
-------------------------------------------------------------------------------------
MATLAB Version 7.13 (R2011b)
Database Toolbox Version 3.10 (R2011b)
MATLAB Compiler Version 4.16 (R2011b)
}
Note that I am running MATLAB Version 7.13 and MATLAB Compiler Version 4.16...which begs the question: what version of the MCR is my compiled code dependent on? If it is 7.13 (because that's the version of MATLAB my code is known to work under), then the Compiler (which installs the MCR, correct?) installed the wrong MCR version for my MATLAB installation. If it is 7.16 (because that is what ships with the Compiler Version 4.16), then I will need instead a version of the Compiler/MCR package consistent with version 7.13 of MATLAB, as that is the version my code is known to run under, and we are not prepared at this time to upgrade it to 7.16."
FWIW,
DG

Melden Sie sich an, um zu kommentieren.

Antworten (5)

Image Analyst
Image Analyst am 14 Jan. 2013
Bearbeitet: Image Analyst am 14 Jan. 2013

0 Stimmen

10 Kommentare

David Goldsmith
David Goldsmith am 14 Jan. 2013
Bearbeitet: David Goldsmith am 14 Jan. 2013
I don't understand: isn't the compiler's dependency analyst supposed to figure out what's needed and automatically include that in the package? (That's why I'm incredulous that I have to explicitly include some files--there are many, both in the main's source code folder and not, but all are on my Matlab path at compile time--but not others.) One of us doesn't understand the other: I wasn't talking about putting or referencing files (or not) in post-build directories--I didn't think/know that was necessary...is it? (It hasn't been necessary for another app I'm compiling: I was able to use the prj I inherited from my predecessor with no such problems and no such actions required, and the app it produces from my source runs just fine.) And none of what you say clarifies why Matlab would be complaining about not being able to checkout a license for one of my source code files.
Image Analyst
Image Analyst am 14 Jan. 2013
Bearbeitet: Image Analyst am 14 Jan. 2013
The compile process will find any needed .m files but not other files such as DLLs, documentation, mat files, Excel workbooks, splash images, data files, etc.
Look into the license() command. For example:
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
It has various codes that tell you if you don't have the license or if you have a floating license but all copies of it are in use at the moment.
David Goldsmith
David Goldsmith am 14 Jan. 2013
Bearbeitet: David Goldsmith am 14 Jan. 2013
The files it is complaining that it can't find ARE m files. The file it is complaining it can't checkout a license for is one of MY m files (which it DOESN'T complain about not being able to find, BTW), not a Matlab file.
Image Analyst
Image Analyst am 14 Jan. 2013
That doesn't make sense. It should never complain about not finding an m-file. Did it make an "excluded files.log" file or something like that? What's in it? Also, please provide all of the stuff spewed out to the console window when you run your program. Open a console window and run it from the OS prompt if you have to (to get the error message to stay there and not vanish). Lastly, you can call the Mathworks and ask them.
David Goldsmith
David Goldsmith am 15 Jan. 2013
"That doesn't make sense." No duh--that's why I'm having problems (I'm not a novice, not at Matlab, nor at compiled languages).
Here is the entirety of the mccExcludedFiles.log:
"This file contains the list of various toolbox functions that are not included in the CTF file. An error will be thrown if any of these functions are called at run-time. Some of these functions may be from toolboxes that you are not using in your application. The reason for this is that these toolboxes have overloaded some methods that are called by your code. If you know which toolboxes are being used by your code, you can use the -p flag with the -N flag to list these toolboxes explicitly. This will cause MATLAB Compiler to only look for functions in the specified toolbox directories in addition to the MATLAB directories. Refer to the MCC documentation for more information on this."
Nada.
Here's the console output (the File Not Found is an expected output of my program, not a Matlab complaint):
"Y:\SHARED Files\MWDataMgmt\VSS_Mirror\executables\ProcessFlights32\distrib>Proce ssFlights32
Y:\SHARED Files\MWDataMgmt\VSS_Mirror\executables\ProcessFlights32\distrib>File Not Found
Y:\SHARED Files\MWDataMgmt\VSS_Mirror\executables\ProcessFlights32\distrib>"
(Note: as a result of my having explicitly included in the build project both of the m-files whose functions it complained about not finding, the program no longer crashes, but it still throws the "Unable to check out a license" error--it's not in the console output because I catch it in the program and report it in the program-generated log file; the ultimate use of the app is as a batch program, so we want to catch and log, not throw to a non-existent console window, any error messages.)
I called Matlab (thank goodness we have a "maintenance" license with them): I stumped the "stock" tech support guy. He's supposedly consulting with his experts; he emailed me a list of follow-up questions to which I have responded; I await his reply.
Image Analyst
Image Analyst am 15 Jan. 2013
Sometimes you do have to include an m-file in the mcc line (I found out today) - when you are calling a DLL because you can't use the h file like you can in the development environment, you have to create a "prototype" file, which is an m-file and it won't get found unless you explicitly include it with the -a option of mcc. Anyway it sounds like you have that part solved.
For the remaining license check out issue. You aren't by chance running this on a multi-user system under a different account are you? Can you install the MCR and exe on your system and run it? Does it work fine there, and is it just on the target system where it complains about the license? Or does it make the same complaint on both systems?
David Goldsmith
David Goldsmith am 15 Jan. 2013
"You aren't by chance running this on a multi-user system under a different account are you?"
No. (The build target is on a network drive, but my understanding is that, nevertheless, if I'm logged in to my acount on my machine when I run the exe from the network drive, it runs on my machine, i.e., appropriates memory on my machine, uses its CPU, etc.--is this not the case?)
"Can you install the MCR and exe on your system and run it?"
I already have the MCR installed on my machine...however, this lead may have just hit pay dirt: I'm successfully running the ap in Matlab R2011b Ver. 7.13.0, but the MCR I have installed is v716. I'll try to get my hands on a v713 MCR and see if that makes the difference. Thanks for the lead.
Image Analyst
Image Analyst am 16 Jan. 2013
Bearbeitet: Image Analyst am 16 Jan. 2013
I'm surprised that you would get that kind of error message. Usually you get a message something like "You need to have MCR version 7.13 installed" instead. I'm really puzzled sure why you didn't get that. But the MCR installed on the target machine must match that you used to compile it with. You can find the proper MCR on your computer in the C:\Program Files\MATLAB\R2012b\toolbox\compiler\deploy\win64 (or similar) folder. I believe all the current and past MCRs are also available on the Mathworks web site.
Walter Roberson
Walter Roberson am 16 Jan. 2013
Only R2012a and R2012b MCRs are available for download, as far as I have heard.
David Goldsmith
David Goldsmith am 16 Jan. 2013
Right, that's all I was able to find.

Melden Sie sich an, um zu kommentieren.

Walter Roberson
Walter Roberson am 15 Jan. 2013
Bearbeitet: Walter Roberson am 15 Jan. 2013

0 Stimmen

A couple of possibilities:
Question: is your code changing directories? Is the MATLAB path what you expect when the problem occurs?

2 Kommentare

David Goldsmith
David Goldsmith am 15 Jan. 2013
Excellent leads, Walter, thanks! I'll "run them down" and report back.
"is your code changing directories?"
Yes.
"Is the MATLAB path what you expect when the problem occurs?"
I'm not sure: what should I expect it to be? (I cd to a directory resulting from a call to which:
[BaseDir,~,~] = fileparts(which('ProcessFlights'));
cd(BaseDir)
The directory this cd's to appears to be a compiler construct:
C:\Users\dgol461\AppData\Local\Temp\dgol461\mcrCache7.16\Proces23\ecylcyfsvrxfile\eap\SHARED Files\MWDataMgmt\VSS_Mirror\rt\Flights
I certainly never consciously nor intentionally created such a directory.)
For the time being, the "Undefined function" error has been eliminated by explicit inclusion of the "missing" files in the build project's additional files list, so my sole focus now is on solving the "Unable to checkout a license for" error.

Melden Sie sich an, um zu kommentieren.

Walter Roberson
Walter Roberson am 16 Jan. 2013

0 Stimmen

The MCR version absolutely must match the compiler version.

2 Kommentare

David Goldsmith
David Goldsmith am 16 Jan. 2013
Am I correct in inferring/thinking that:
A) folder name v716 => Version 7.16?
B) the Compiler toolbox is responsible for installing the correct MCR version?
C) If my MATLAB version is 7.13 then the Compiler should have installed MCR 7.13?
D) If it didn't, that's a bug I should report?
Thanks!
David Goldsmith
David Goldsmith am 16 Jan. 2013
"False Alarm": According to the following link:
4/7.16 is the correct C/MCR for R2011b(7.13).

Melden Sie sich an, um zu kommentieren.

David Goldsmith
David Goldsmith am 17 Jan. 2013

0 Stimmen

More data: I started from scratch, i.e., I built my own project (I have been working with someone else's, and no, he's not available to help me debug this), starting w/ the minimum of what I thought should work and gradually building up from there to see where it would start working. First, a little "back story": I develop on my local drive, then check working code into a repository on a network drive. When I started from scratch, I tried to build the project using only files on my local drive (since those are what Matlab uses to run the program successfully in the interpreter)--no matter how much I included, I couldn't get past the "old" "UndefinedFunction" error (which makes the program crash before it ever gets to the "Unable to checkout a license" error.) So, retaining the local version of my main file, I included the network drive versions of the two files in which the undefinded functions are defined: that got rid of both of those errors, returning me to the "Unable to checkout" error state. However, when I replaced the local main file w/ its network drive equivalent (still keeping the network drive version of the other two "problem" files), I regressed back to the Undefined function error. I returned to the local version of the main and the network version of the problem files and I got back to the Unable to checkout error.
This data doesn't mean much to me, but hopefully it will mean something to someone reading this.
DG

4 Kommentare

Image Analyst
Image Analyst am 17 Jan. 2013
How exactly did you tell the compiler to use the local or network version of the files? It goes through the search path to determine which dependent m-file(s) to use. Did you adjust the path?
David Goldsmith
David Goldsmith am 17 Jan. 2013
Using deploytool, under the Build tab, there are two panels, one for selecting the Main File, one for selecting Additional Resources and Helper Files; I used the file choosers these provide to navigate to the files. Then, to confirm, I right-click on the displayed filenames, which displays a popup that includes a "Locate on Disk" command; according to this, the compiler is using what I pointed to. (Or, if you prefer to look at it this way, if that functionality is working correctly and correctly showing me what the compiler is in fact using, then, according to that function, what I reported is what was used.)
I'm not sure I trust that. Sure it may include that file on the the network disk, but when it comes time to actually call the function it will see two versions of it - the network one and the one in the same folder. Then it has to decide which one to call. So even though you included that file, it may not be the one it calls. I'd put in a message box to verify,
uiwait(msgbox('Calling network file'));
or
uiwait(helpdlg('Calling local file'));
Then see if the network one is actually the one being used. Anyway, the compiler is a very expensive toolbox. Make sure you get your money's worth and call tech support. Can you do that? Did you buy it within the last year or are current on your maintenance contract?
David Goldsmith
David Goldsmith am 17 Jan. 2013
I called MathWorks support Monday and have been iterating w/ them since(though they've mostly been working on the licensing issue, as I at least have a "workaround" for the undefined function problem); they have me doing increasingly advanced things (running it in DependencyWalker and monitoring it w/ ProcessMonitor) and feeding them the output: they're still stumped (presently, they're hoping it's due to a third-party oceanographic library I use called SEAWATER, but if this is the case, it would be a new phenomenon, i.e., I've used it for about 2.5 years now with no problem).
Thanks for the suggestion (it took me a moment, but I figured out that you meant put the one only in the network version and the other only in the local version). :-)

Melden Sie sich an, um zu kommentieren.

David Goldsmith
David Goldsmith am 18 Jan. 2013

0 Stimmen

Here's the email I just sent my support person (explains where I am/what I'm doing now):
Given that it was necessary to build a "mixed" version (referencing the local copy of my main file, but including the network versions of (only) a couple of the function definition files it depends upon) to even "workaround" the seemingly more fundamental problem of Undefined function errors, and given that I'm able to run the un-compiled source code "inside" Matlab without incident (just re-confirmed for the umpteenth time), my next step was to determine if the latter success was being made possible by the presence in my Matlab path of those network directories; according to the Set Path dialog, I have only local (C:) drive directories on my Matlab path. The facts that, under such conditions, the program source runs inside Matlab but the compiled version complains about an Undefined function tells me that, essentially, there is still something fundamentally wrong with either my source code, and/or the way in which the compiler is trying to put it all together. Thus my goal at present is to build a correctly running compiled version referencing only the files I have on my local drive, ignoring, for the time being, any problems I may have with how my VCS is updating files on the network drive--until I can get a working compiled version using only files I know to work inside Matlab, the network drive/VCS issue seems secondary.
So, to recap: I have a large, pure-Matlab code-base that runs fine inside Matlab, and appears to compile fine, but when I run the compiled version, crashes with an "Undefined function" error. (I have another code base that shares some of the same code and compiles and runs fine, but, notably, the overlap does not include the files about which the problem compiled complains.)

Kategorien

Mehr zu Install Products finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 14 Jan. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by