Standalone compiled with Matlab compiler doesn't work on other computers.
Show older comments
I have compiled a .exe file using Matlab compiler which works fine on my computer, but when I try to run it on any other computer it crashes on startup. I have made sure that the target machine has the correct version of MCR and I have followed the directions listed here for debugging:
Furthermore, when I tried using DependencyWalker as step 4 from above, I get the same results from the following page, but none of the answers there have solved my problem.
If anyone could point me in the right direction it would be greatly appreciated!
4 Comments
Von Duesenberg
on 7 Mar 2018
A couple of years ago, I had a similar problem which was caused by something in the startup file on my development computer. Unfortunately I don't remember exactly what it was (possibly a 'cd' command), but then I removed it and everything worked fine.
Nick Ballard
on 9 Mar 2018
Kelly Kearney
on 9 Mar 2018
I know nothing about compilation issues, but...
A single-line startup.m file with a load matlab.mat sounds like the default startupsav.m example file, which is designed to be paired with the example finishsav.m example. These examples work to save the working environment to a .mat file on closing Matlab, and reload it on startup.
It sounds like this particular startup file is not really being used on this machine. So I'd recommend just deleting it. The startup file is only needed if you want to custom configure details every time you run Matlab. (And if you do have custom instructions, such as cd-ing to a specific working directory, you'd better be sure all code you run, compiled or not, is robust to that.)
Nick Ballard
on 9 Mar 2018
Answers (2)
Image Analyst
on 9 Mar 2018
You can put it in a try catch
try
load('matlab.mat');
catch
end
Or you could check if the application is deployed
if ~isdeployed
load('matlab.mat');
end
Of course if the file is essential then you'll have to find it. Try specifying the full path where it's known to live.
4 Comments
Nick Ballard
on 9 Mar 2018
Image Analyst
on 9 Mar 2018
Your startup.m file will run on your target computer first before your actual code runs. Using try catch will prevent the program from completely vanishing if there is an error. If your startup.m file has code that you do want to run in your development environment but not in the standalone program deployed to your target computer/end user, you can wrap stuff in it like this:
if isdeployed
% Code that runs only in standalone program
else
% Code that runs only in development environment (MATLAB)
end
% Code after that (i.e. down here) will run in both environments.
Nick Ballard
on 9 Mar 2018
Image Analyst
on 9 Mar 2018
It's hard to help if I don't have your executable or the source code. If you've done everything in the FAQ then you might have to call the Mathworks. They can see and drive your computer to get it figured out. However in my experience, most compiled problems are due to the file not being on the search path or in the expected folder. Make sure you make your program robust by using "if !exist(filename, 'file')" before any line of code where you try to use a file.
Nick Ballard
on 13 Mar 2018
0 votes
1 Comment
Image Analyst
on 13 Mar 2018
Yes. That's number 10 on the FAQ list I referred you to. So, could you go ahead and "Accept" my answer above? Thanks in advance.
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!