Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Make 32 and 64 bit executable?

Asked by D G on 11 Jul 2012

Hello!

I have a script that makes an executable for an application. We used to just create a 64bit executable, but now we want a 32bit executable as well. I installed the 32bit MATLAB, but now whenever I create the 64bit executable it crashes right after starting (Windows', "x.exe has stopped working" error).

I have tried changing the compiler, but it has not had an effect.

How can I fix this?

Thanks!

0 Comments

D G

Products

2 Answers

Answer by Image Analyst on 11 Jul 2012
Accepted answer

What crashes: MATLAB while compiling, or your application while running on the target computer? You need to be running the 32 bit version of MATLAB when you compile an executable for a 32 bit computer, and you need to be running the 64 bit version of MATLAB when you compile an executable for a 64 bit computer. You can do both of these on your 64 bit computer - you don't need a 32 bit computer. But you do need to re-run "mbuild - setup" (or so I've been told) whenever you switch from compiling on one version to compiling on the other version.

5 Comments

Kaustubha Govind on 11 Jul 2012

Perhaps you could try starting the application from a command window (as opposed to simply double-clicking on the icon) - often times, error messages are displayed on that command window, which might tell you something about why the application crashes.

D G on 11 Jul 2012

I think I have narrowed down the problem. It appears that the application crashes only when running on a machine that has both 32 and 64 bit versions installed. It appears that MATLAB is trying to run the 64 bit exe with 32bit MATLAB.

Any thoughts on this?

Image Analyst on 11 Jul 2012

I might be able to see that happening on a 32 bit machine. The executable is not really the executable but rather a self extracting archive that unpacks the real executable and a bunch of other stuff to a hidden folder in your c:\users\Daniel\.... folder. And that is the one that actually gets run. If you run it again, I think it doesn't need to unpack the stuff and just goes right there to run it immediately. However if you tried to run your 64 on a 32 machine, and then it failed, and then tried to run the 32 bit executable, it might see that hidden stuff if unpacked and decide it doesn't need to do it anymore. Unfortunately it would then be running the 64 bit version which failed, rather than unpacking a new 32 bit version. So it would crash again. Put this line in your code to see where it actually is running:

fprintf('MATLAB is actually running from %s\n', ctfroot);

Since you paid a ton of money for the compiler, I suggest you ask the Mathworks for all the details. You can change where it unpacks all the stuff by changing the MCR_CACHE_ROOT environment variable to dot if you don't want all this stuff buried in some secret hidden folder. (Ask them how).

Image Analyst
Answer by hana on 11 Jul 2012

you have to compile the 32bit executable on a 32bit machine and the 64bit one on a 64.

2 Comments

Image Analyst on 11 Jul 2012

Not true.

Walter Roberson on 14 Jul 2012

Image Analyst is correct: compiling for 32 bit machines on a 64 bit machine has been officially supported for a couple of releases, and technical solutions were made public for how to do it for a couple of releases before that.

hana

Contact us