MATLAB Compiler (Win32)

posted in: MATLAB (MATrix LABoratory) | 0

I want to be able to run Matlab a m-file as an executable file (exe) in Windows, hence it is not needed to open Matlab. That means that I need to compile the corresponding Matlab m-file to an Windows executable file, therefore it is needed to compile the m-file to exe file. In addition, by having a compiled exe file, it can be used in other computers which have no Matlab installed.

The process of installing and using Matlab compiler is as follow;

Exit Matlab if it is running.

Install / Run: MCRInstaller.exe which is located in:
C:\Program Files\MATLAB\R2008b\toolbox\compiler\deploy\win32\MCRInstaller.exe

Start Matlab an issue the following command:

>> mbuild -setup (enter)

Please choose your compiler for building standalone MATLAB applications:

Would you like mbuild to locate installed compilers [y]/n? y

Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2008b\sys\lcc

[0] None

(choose available compiler, in this case 1)

Compiler: 1

Please verify your choices:

Compiler: Lcc-win32 C 2.4.1
Location: C:\PROGRA~1\MATLAB\R2008b\sys\lcc

Are these correct [y]/n? y

Trying to update options file: D:\Documents and Settings\09871962\Application Data\MathWorks\MATLAB\R2008b\compopts.bat
From template:              C:\PROGRA~1\MATLAB\R2008b\bin\win32\mbuildopts\lcccompp.bat

Done . . .

Now you can compile any Matlab m-files into a standalone exe files in Windows. For example, to compile m-file called

myfile, issue the following command:

>>mcc -m myfile.m (enter)

If there are no error, Matlab will generate myfile.exe and
return to its normal prompt >>.
Open Command Prompt and test run myfile.exe.