MATLAB: Generating Standalone Executable file Using Matlab Coder

executablematlab coderMATLAB Compilerstandalone

Hi,
I want to create a Standalone executable file from my Matlab code. I used "mcc" command and I got the exe file, but it just works on the computers which have Matlab. I want an Executable file to work on the computers without Matlab installed.
I tried using Matlab Coder to generate C++ code from my matlab code. I found that for some sort of functions such as "plot". We need to call them as the Matlab extrinsic function which means still we need Matlab on the computer to run the standalone executable file.
Could you please advise me how I can generate standalone executable file from my Matlab code in a way that it works on the computer without Matlab installed?
Thanks, Mohammadreza

Best Answer

There are two separate MathWorks' products that you are seemingly confused between:
1. The "mcc" (and "deploytool") command belongs to MATLAB Compiler , which can generate executables , DLLs, etc. from MATLAB code, but still call into MATLAB runtime libraries. You need to install the MATLAB Compiler Runtime (MCR) on the deployment machine to run binaries produced by MATLAB Compiler.
2. Completely standalone code can be generated using MATLAB Coder when using functions supported for code generation . The concept of "extrinsic" functions belongs here, where you can call into a function not supported for code generation, but the generated code will contain a dispatch to MATLAB. This is useful when generating MEX-files from MATLAB code which is an equivalent of a DLL/shared library that can be run only inside MATLAB.
There is currently no way to generate completely standalone code from functions like "plot" which are not supported for code generation with MATLAB Coder. The only option is to use the "mcc" command from MATLAB Compiler, and install the MCR on your target machine.
This link provides more info about using MATLAB Compiler and MATLAB Coder.
This topic shows an example of how to generate a standalone executable from MATLAB Coder, including the step of creating your own C main file.
Related Question