How to generate and run executable on the same Linux machine
For MATLAB Compiler Version 4.7
The instructions for generating a standalone executable in this page is for MATLAB 7.5 (or MATLAB 2007b), with the compiler at version 4.7. Different versions of MATLAB may require somewhat different procedures for creating standalone executables. Make sure to use the instructions that correspond to the compiler available on the machine you intend to use to generate standalone executables.
MATLAB 2007b (with Compiler 4.7) is the current default version on the Linux and Katana clusters:
cootie% matlab
Here is a way to find out what version of MATLAB and its toolboxes you have:
>> ver % this produces a list of toolboxes (including the
% compiler) and their version numbers
Create a standalone executable (on the SCV Linux and Katana Cluster)
- Create a new directory and copy all required files (in this case: myexample.m, filea.m, and fileb.m) into it.
>> mcc -o myexample -m myexample filea fileb % compile myexample.m filea.m fileb.m
The mcc command above compiles myexample.m, filea.m, and fileb.m into an myexample executable, along with a bunch of additional files, including a script called run_myexample.sh. To run myexample as a standalone, execute run_myexample.sh at the unix prompt. See below for details.
Run the standalone executable (on the SCV Linux and Katana Cluster)
To run myexample as a standalone, you should execute run_example.sh instead. Admittedly, this is nonintuitive, probably even unexpected if you have used the older mcc compiler in the past.
katana % run_myexample.sh $MATLABROOT > myexample.out
where $MATLABROOT is /usr/local/apps/matlab-2007b.
The above run does not require a MATLAB license.
The following procedure may be used to verify that a standalone exec does not require a MATLAB license:
- Run the standalone exec
- In a MATLAB window (on Katana)
>> [s, w] = unix('/usr/local/matlab/etc/lmstat -a -c ... /usr/local/matlab/licenses/network.lic | grep USERID')where USERID is your user ID.
- Or, at the unix prompt
katana% /usr/local/matlab/etc/lmstat -a -c /usr/local/matlab/licenses/network.lic | grep USERID
In connection with the compiler, MATLAB 7 provides a new utility called ISDEPLOYED. Here is the description, according to the MATLAB help file:
ISDEPLOYED tests if the code is running in deployed mode or MATLAB mode X = ISDEPLOYED returns true when the function is being run in deployed mode and false if it is being run within MATLAB environment.
This utility lets you know in what mode (MATLAB or standalone) the code is running. This is quite useful. In older versions, the compiler does not support GUI of toolboxes in a standalone. In the interests of maintaining a single source file for both the MATLAB and standalone modes, you could use ISDEPLOYED to determine at runtime whether to branch into the GUI section of the code. Other similar situations that depend on whether the job runs in the MATLAB or standalone modes may also warrant the use of ISDEPLOYED.
Source: MATLAB 7.4 documentation on MATLAB Compiler.
![]()



