MATLAB Answers

0

Generating Standalone Executable file Using Matlab Coder

Asked by Mohammadreza on 8 Dec 2011
Latest activity Edited by MathWorks Support Team on 9 Nov 2018
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

  0 Comments

Sign in to comment.

6 Answers

Answer by Kaustubha Govind on 8 Dec 2011
Edited by MathWorks Support Team on 9 Nov 2018
 Accepted 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.

  5 Comments

Hi, I want to make a standalone program from Simulink file .mdl. So that if I do not install Matlab in one pc, I can still run the program. Is it possible to do this? Never done this before, please give some hint. Thanks!
BuEr
Buer: I have already answered your question here.
i am trying to convert my matlab files in to exe, when i type deploytool in command window, it's not appearing as attached image. Please anyone help me how to make exe file from .m files

Sign in to comment.


Answer by Dr. Seis
on 8 Dec 2011
Edited by John Kelly on 13 Nov 2013

Check out this "deploytool" tutorial: Here
After packaging your standalone following these steps, does it still not work on a non-Matlab machine?
I have run into issues associated with dynamically linked libraries, but all of the computers that run my standalone programs can access it at run-time provided I supply the path to its location (so it isn't as big a deal).

  3 Comments

Thanks Elige, it is really helpful. I used mcc command and developed executable file. Then I used the package option in deplytool to generate the MCRinstaller in my computer which has windows 7 operating system. But when I want to install MCR on another computer which has also windows 7 operating system, I get an error regarding having incompatible system and MCR can not be installed and I should contact the Vender. Do you know how I can solve this problem of incompatibility?
Thanks for your time.
Is it because you are running a 32-bit operating system? I had a similar problem until I ran it on my 64-bit laptop and then it worked no problem
Added this answer to the other one describing the two products together. Both bits seem helpful.

Sign in to comment.


Answer by Peyman Obeidy on 17 Dec 2016

can we do this for scripts or you can only make standalone from GUI?

  2 Comments

Earlier versions of MATLAB could not compile scripts; newer ones can. However, it compiles it by effectively adding on a "function" heading with a function name the same as the script file name. MATLAB Compiler is happy to compile routines that do not use graphics; it could always do that for functions that did not happen to use graphics, and as mentioned above it can now do so for scripts that do not happen to use graphics.
MATLAB does not distinguish between "figure" and "GUI": as far as MATLAB is concerned, every figure window is a GUI and every GUI is a figure window.
Perhaps what you are trying to refer to is "console apps", where no graphics is created and any interaction happens at the command line using text only. For that, generate it as a "standalone application" but not as "standalone application without console window". If you were using mcc then you would use the -m option but not -e .
Thank you, Walter, I save the script as a function and package it. It is working fine.
Best regards Peyman

Sign in to comment.


Answer by reeva M
on 30 Sep 2017
Edited by Walter Roberson
on 9 Oct 2017

x=-pi:0.01:pi;
y=sin(x);
subplot(2,4,1);
plot(x,y);
title('sine wave');

  0 Comments

Sign in to comment.


Answer by Mahalakshmi Venkatesh on 9 Oct 2017
Edited by Walter Roberson
on 9 Oct 2017

When I try the 'guide ImpulseResponseAnalysis' command, I et the following error:
Error using guide (line 134)
File 'ImpulseResponseAnalysis.fig' not found.
Is there a way around this? :)
Many Thanks,
Mahi

  1 Comment

ImpulseResponseAnalysis.fig does not appear to have been provided with MATLAB and does not appear to be in the File Exchange, and I do not find it anywhere online. If you are trying to create a new GUI by that name, just start up guide, create a GUI, and tell guide to save it under that name.

Sign in to comment.


Answer by Ridvan Taskiran on 3 May 2018

hi . I need help about this application. I prepared application but when I started it, it waiting on the screen and nothing happen. How can I solve this problem?

  0 Comments

Sign in to comment.