MATLAB: How to reduce the size or footprint of a stand-alone application I bundle for deployment using MATLAB Compiler 3.0.1 (R13SP2) or earlier

bundledependenciesdependencydllexecutablefootprintlargeMATLAB Compilerreducestand-alone

It seems that every time I create a MATLAB executable, I have to bundle the large set of DLLs from the MGLINSTALLER regardless of how simple the actual application. I would like to know if there is a way that I can reduce this large footprint or even replace some of the DLLs that are not used with dummy or empty files.

Best Answer

Note that the MATLAB Compiler was re-architected between MATLAB R13 and MATLAB R14. Thus this solution applies only for stand-alone applications created using the MATLAB Compiler 3.0 (R13) or earlier.
The footprint of MATLAB Compiler generated applications is larger than necessary because the shipped libraries have most of the functionality of MATLAB in them, and MATLAB is a big program. The libraries also have a very complicated set of interdependencies. It is very unlikely that you will be able to simply remove (or replace with an empty dummy file) any of the libraries.
However, to theoretically reduce the footprint size (and it is NOT easy) you must find all the libraries that your application does not need and replace them with dummy DLLs of the same name. These DLLs need only have the standard DLL functions in them (DllMain, etc). You can only make this replacement if you eliminate all the DLLs that depend on this DLL as well (Note that this is the hard part and we do not have such a list in-house). For an expert C programmer, this could easily take more than two weeks, if not a full month, to complete.
The interdependencies also will vary for different MATLAB applications. The tradeoff is that you have the ability to build robust applications using the advanced mathematical and graphic capabilities of MATLAB with relative ease.
Note that if you are deploying multiple stand-alone MATLAB applications on the same computer, you will need only one installation of the MGLINSTALLER. Essentially, once the MGLINSTALLER has been made available on a particular computer, you will only need to distribute the .exe, data files, the bin directory and custom MEX-files required by the executable.
NOTE: The developers at MathWorks are aware of this and MATLAB R2016a Prerelease addresses this limitation in that, if the function that is being deployed contains only mathematical computations, it will bundled with a smaller version of the MCR.