The ability to add custom icons natively in a compiled application is available in the deploytool with release R2013b.
This is not possible in releases R2010b - R2013a.
If you are using MATLAB compiler 4.13 (R2010a) or before see below for any workarounds:
There are two ways to include a custom icon in a compiled application. One way is to modify the icon after the EXE has been generated using 3rd party software. The other way is to include the icon at compile time using a resource file. Each of these is explained further below.
1. In order to associate an icon with an application after the EXE has been created, you will need to use a 3rd party tool to modify the icon. There are many applications available for this purpose. A good place to start is by searching the "Downloads" area of some popular sites like http://www.pcworld.com/ and http://www.cnet.com/.
2. If you wish to include the icon at compile time, you will need to make sure that your compiler supports this. The general process is to create a resource file which points to the icon, compile it with a resource compiler, and then include the compiled resource file when compiling the application.
Steps for MSVC Compiler:
1. Create a new Win32 Console Application
2. Right-click on "Resource Files" then select "Add->New Item"
3. In the new window, under "Visual C++", select "Resource"
4. Then in the "Visual Studio installed templates" section, select "Resource File (.rc)"
5. Specify a name for the resource file and click on "Add"
6. Right-click on "Resource Files" again and choose "Add Resource"
7. Select "Icon" and click "New"
8. Create the icon
9. Build the solution (F7)
10. Copy the generated .res file to the folder with the MATLAB code
11. Compile the MATLAB code:
mcc -m myfile.m -M icon.res
where icon.res is the compiled resource file. You can use the "-M" flag to specify compile-time options to your specific compiler. Type
for more information about this flag. These steps may vary depending on which version of Microsoft Visual Studio you are using. If you are not using a Microsoft compiler, you may want to see if your 3rd party compiler supports icon files.
Steps for LCC Compiler:
1. Let the icon file be named 'ship.ico'. If you have an image file (*.JPEG, *.TIFF, *.GIF, *.PNG...), you will need to use a 3rd party tool (you can search online for an image converter) to convert your image to a .ICO icon file.
2. Create a new text file and write "ConApp ICON ship.ico" in it. Rename it as "example.rc" and save it in your current directory.
3. Compile "example.rc" and "ship.ico" files using the following command at MATLAB prompt:
system(['"' matlabroot '\sys\lcc\bin\lrc" /i "' pwd '\example.rc"']);
After this step you will have a resource file "example.res" created in your working directory.
4. Compile the MATLAB files and the resource file together using the -M option as before:
mcc -m file1.m -M example.res
where file1.m can be any MATLAB File you want to deploy. This will create a "file1.exe" in your working directory with the same icon as "ship.ico".
If you are using MATLAB compiler 4.14 (R2010b) then see below:
Steps for MSVC Compiler:
Here instead of creating a '.exe' file, you will need to create a C shared library and write wrapper driver code that calls the main function of the application. More information about this can be found in the link below.
A custom icon can then be associated with the EXE that is created when the driver code is compiled. For the sample driver code we are using FIGURETEST as the MATLAB function compiled into LIBFIGURE.DLL. Please follow the steps below once your DLL is created:
1. Create the C shared library using the link above.
2. Create a new Win32 Console Application named "test".
3. Right-click on "Resource Files" then select "Add->New Item"
4. In the new window, under "Visual C++", select "Resource"
5. Then in the "Visual Studio installed templates" section, select "Resource File (.rc)"
6. Specify a name for the resource file and click on "Add"
7. Right-click on "Resource Files" again and choose "Add Resource"
8. Select "Icon" and click "New"
9. Create the icon
10. Build the solution (F7)
11. Write your driver code in test.cpp and compile the VC++ console application by correctly providing the path to your library. Sample driver code is as follows.
// test.cpp : Defines the entry point for the console application.
// libfigure is the Shared Library
// Figuretest() is the main function in the library which corresponds to the
// figuretest() function in the .m file which was compiled using mcc
int _tmain(int argc, _TCHAR* argv)
// Have to find out the paths
if( !mclInitializeApplication(NULL,0) )
fprintf(stderr, "Could not initialize the application.\n");
// Initialize the library
fprintf(stderr,"Could not initialize the library.\n");
//Call the figure library
Steps for LCC Compiler:
There are no workarounds other than using third party products to insert the icon after compiling the application.