Thilina's Blog

I might be wrong, but…


When you using your MATLAB programs such as GUI related things its bit messy to run MATLAB and then to run your MATLAB scripts since MATLAB takes some time to run and it uses more resources from your computer. So it’s very easy if we can run our MATLAB applications without running MATLAB. The MATLAB compiler gives us the opportunity which to convert our m-scripts to exe files. In this article I’ll try to share my experiences on configuring MATLAB compiler and to deploy a MATLAB script to an *.exe file.


Make sure you got installed ANSI C or C++ Compiler in your computer. First type ‘mbuild -setup’ on your MATLAB command prompt.


Press ‘y’ and Enter to continue on operation (Pressing <ENTER> is also sufficient since the default answer is [y].) Then MATLAB will list down all the compilers you have installed in your computer and prompt you to select a compiler to use.


I choose ‘Microsoft Visual C++ 2008 SP1 in C:\Program Files\Microsoft Visual Studio 9.0’ as my compiler, so I enter ‘2’.


After selecting the compiler MATLAB asks to verify it and to confirm. To continue, press <ENTER>. Now you are done with configuring MATLAB compiler on your computer.


Next lets see how to deploy m-scripts to *.exe and to make packaging for m-scripts.


For the deployment I use the files I programmed for my previous article on MATLAB GUI programming. To select the deployment tool you can either select deployment tool by ‘Desktop’ tab in MATLAB (Desktop>>Deployment tool) or By File>>New>>Deployment project.

When you select new deployment project ‘Deployment Project’ Window will be opened and prompt you to set file location and project name as follows. I select the target result as Stand-alone application, but you can select whatever you want from the drop down menu. Then click <OK> to continue.


Lets first look how to build the project on MATLAB and then to package the project. Go to the build tab on Deployment tool and click add main file link to add your entry point to the program. This is the m-file which you run to start your MATLAB application. For my application main m-file is ‘paint_effect_gui.m’. And then click on ‘add files/directories’ link to add other related files to the project.


Then finally click on built icon to build your project. It will take some time to build your project, you can see the pop-up window which shows the build log as below.


Your project fill be now saved in the ‘proect location/project_name/distrib’.


For package the project click on the package icon and it will package your project. Note that the second icon is the package button.


In-order to start new deployment project or to set other options click on actions icon.


Thank you very much for reading.


2011 February 5 - Posted by | MATLAB


  1. Thilina this is excellent piece of work.Keep it up 🙂

    Comment by Shelan Perera | 2011 February 5 | Reply

    • Thank you very much bro 🙂 🙂

      Comment by Thilina S. | 2011 February 5 | Reply

  2. Keep it up brother unleash ur knowledge to the masses… 🙂

    Comment by bana | 2011 March 8 | Reply

    • he hee…, Thanks Banu 🙂 🙂

      Comment by Thilina S. | 2011 March 8 | Reply

  3. Hey there!
    Thanks for the information. It really helped me for my problem and wish you success for your undergraduate study!
    Best wishes from Turkey !

    Comment by Fatih | 2011 July 11 | Reply

    • You are welcome 🙂 ,Glad to hear that it helped you. Good luck with your work.!! 🙂

      Comment by Thilina S. | 2011 July 11 | Reply

  4. thanks a lot for the info 🙂 🙂

    Comment by ashwininayak | 2012 January 14 | Reply

  5. HI buddy,
    I have a problem with cross paltform, I have written a program in Matlab which is currently running in windows 7, but I have to compile it such that run later in ubunto platform? is it possible/

    Comment by reza | 2012 March 25 | Reply

    • Hi,
      I am not pretty much sure about that.., but in MATLAB there is an option called include MCR Installer to add an MATLAB framework installer to your program when you compile your program using MATLAB compiler. Maybe by using that you can run your program in Ubuntu as well.

      Comment by Thilina S. | 2012 March 25 | Reply

  6. This is tht I have been looking for. Let me try this. Thank you for the details.

    Comment by Chris | 2012 April 21 | Reply

  7. elaz! ayya.

    Comment by arosha sumanaweera | 2012 November 8 | Reply

  8. Can the tool generate “binary”, the executable for MAC platforms ?

    Comment by BM | 2013 April 1 | Reply

  9. this is really important article. i tried this one but i have got a problem. After i click the build button it says ” building project xxxxxxx” and this take vary long time . do you guys have any idea. Tnx in advance.

    Comment by taboguleza | 2013 April 8 | Reply

  10. Hi thank you very much for this article, maybe you can help me with this issue :
    I was trying to build my project which interact with some C files And when I try to add the header file, an error occurred : You specified file “C:\…\header.h” without using “-a” option. mcc failed.
    Do you know how to solve this?
    Thank you !

    Comment by Ludo | 2013 April 23 | Reply

  11. i am not getting any compiler option though i have already installed ms visual studio 2010. please help me out…what should i do ??

    Comment by gaurav chovatiya | 2013 August 27 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: