Runtime errors in compiled standalone

19 次查看(过去 30 天)
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 个评论
David Goldsmith
David Goldsmith 2013-1-16
编辑:David Goldsmith 2013-1-16
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

请先登录,再进行评论。

回答(5 个)

Image Analyst
Image Analyst 2013-1-14
编辑:Image Analyst 2013-1-14
  10 个评论
Walter Roberson
Walter Roberson 2013-1-16
Only R2012a and R2012b MCRs are available for download, as far as I have heard.
David Goldsmith
David Goldsmith 2013-1-16
Right, that's all I was able to find.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2013-1-15
编辑:Walter Roberson 2013-1-15
A couple of possibilities:
Question: is your code changing directories? Is the MATLAB path what you expect when the problem occurs?
  2 个评论
David Goldsmith
David Goldsmith 2013-1-15
Excellent leads, Walter, thanks! I'll "run them down" and report back.
David Goldsmith
David Goldsmith 2013-1-15
"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.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2013-1-16
The MCR version absolutely must match the compiler version.
  2 个评论
David Goldsmith
David Goldsmith 2013-1-16
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 2013-1-16
"False Alarm": According to the following link:
4/7.16 is the correct C/MCR for R2011b(7.13).

请先登录,再进行评论。


David Goldsmith
David Goldsmith 2013-1-17
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 个评论
Image Analyst
Image Analyst 2013-1-17
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 2013-1-17
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). :-)

请先登录,再进行评论。


David Goldsmith
David Goldsmith 2013-1-18
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.)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by