Building an entirely installation-free Windows standalone via Matlab Compiler - matlab

I'm encountering a serious problem while trying to deploy a Matlab program as a stand-alone for Windows.
My end users are employees in some corporation and have only access to static computers. While they can download, unpack and execute stuff, they don't have installation privileges, so they're unable to install the Matlab Compiler Runtime (MCR). Unfortunately, they need MCR in order to run my deployed/compiled Matlab program. The deploytool offers me the option to "include MCR in the package", but it doesn't really do that. Instead, it packages the MCR installer, which is useless in my case as described above.
So how can I create a stand-alone application that runs on Windows out of the box, even without MCR installed and without installing it first? There has to be a way to compile this all the way down to binary...

You can't run Matlab code standalone without having MATLAB or the MATLAB Compiler Runtime installed. But it is legal to distribute the MCR to the customers to make them able to use your programs.
Alternatively you can use the MATLAB Coder to convert your code to C/C++, which is not completely issue-free, as just a subset of the Matlab language is supported.
Have a look at this question for the differences between MATLAB Coder and MATLAB Compiler.

Just ask IT to install the MCR, that only needs to happen once. After that the users should be able to execute your programs.
Note: There is a reason that the MCR needs to be installed, and can't just be executed. Therefore I don't expect there to be a 'trick' to avoid this.

Related

Force compiled Matlab app to use runtime rather than a Matlab license

My client has a network that doesn't have access to the internet. They intend to buy (very few) Matlab licenses just for the development efforts of me and my colleague. For the operational use by their staff, however, I should compile my Matlab code to *.exe files so that the operators don't use up licenses just to execute my Matlab "app"/"solution" (the language seems to be changing these days). They won't actually have mcc licenses, so the compiling will be done on my home organization's network.
The problem is that when the compiled executable runs, there doesn't seem to be an obvious way to force it to use Matlab Compiler Runtime (MCR). If there are Matlab licenses on the target system, it can use that as well. The whole point of compiling, however, is to avoid using the few licenses on the client network so that the licenses are available for m-file development work when needed. So the unique feature about this situation seems to be that the target environment will eventually have both Matlab licenses and MCR, as well as the requirement that compiled executables use only the MCR rather than the Matlab licenses.
The Mathworks is looking into the problem, but prospects of finding a solution are unclear. I am hoping that it won't involve manual rejigging login scripts to customize environment PATH variables, as that will break whenever login scripts are updated. I'm hoping for a solution like a pragma-like statement in the top-level m-file, or an mcc switch. In perusing the mcc documentation, however, no switches present themselves as likely candidates except for -Y license.lic, and it's not clear how to use that.
With regard to the client, another limitation I face is that I don't want to pester them with trial-and-error (it's not their job). This is complicated by the fact that there is also no efficient way to convey electronic content to them, so quick, iterative trial-and error is out. As well, their target environment, with Matlab licenses, doesn't yet exist, though the process to get there is in the works. It's a bit of an chicken-and-egg problem; they are getting Matlab based on the assumption that we can find solutions for the challenges, but it's hard to derisk the assumption beforehand by investigating solutions when the target environment doesn't yet exist.
On my home organization's system, I also face the limitation that I don't have rights to install MCR. Hence, I can't undertake trial-and-error to identify an incantation or recipe that ignores the presence of Matlab licenses and forces the use of MCR. Not that I have the time to do that, as it is a very inefficient way to achieve this objective.
Because of the many circumstantial challenges, trial-and-error isn't the way to go, and I'm hoping there is a canned method for forcing the use of MCR over any Matlab licenses that might be present. I am using R2015b.
I am working with this exact deployment situation for OS X / Linux with Matlab 2015b. When you compile an application for a Unix-based OS, the compiler creates a shell script that is executed at startup. My solution is to modify this script to check for the presence of the runtime libraries. For example, on OS X (macOS):
echo "Setting up environment variables"
if [ -d "/Applications/MATLAB/MATLAB_Compiler_Runtime/v90" ] ; then
echo "Using MCR v8.6 (R2015b) (_Compiler)"
MCRROOT=/Applications/MATLAB/MATLAB_Compiler_Runtime/v90
elif [ -d "/Applications/MATLAB/MATLAB_Runtime/v90" ] ; then
echo "Using MCR v8.6 (R2015b)"
MCRROOT=/Applications/MATLAB/MATLAB_Runtime/v90
elif [ -d "/Applications/MATLAB_R2015b.app" ] ; then
echo "Using MATLAB R2015b application"
MCRROOT=/Applications/MATLAB_R2015b.app
else
echo "No MATLAB libraries found! Install MCR R2015b from:"
echo " http://www.mathworks.com/products/compiler/mcr/"
echo " "
sleep 10
exit
fi
TMW's response:
Running a standalone application built with MATLAB Compiler will not check out any licenses whether running against an installed MATLAB Compiler Runtime or the runtime installed as part of a MATLAB Compiler installation. Note that end users with MATLAB installed without MATLAB Compiler will not have the compiler runtime libraries included with their installation.
If you have installed the MATLAB Compiler Toolbox, MATLAB will have a "runtime" folder with the necessary DLLs to execute the standalone application. Without the MATLAB Compiler Toolbox, these DLLs will not be available. Instead the user must install MCR to run the standalone application...the user cannot forgo the installation of MCR if they do not have the MATLAB Compiler Toolbox installed and they wish to run the standalone application.

How to run a Matlab GUI program without having Matlab installed?

My program performs some simple calculations, look-ups and outputs an answer. What is efficient way to use a Matlab GUI program like I have as a standalone desktop application, which does not require Matlab as a prerequisite?
In order to run any Matlab program on a machine that doesn't have Matlab installed you will need to instal the Matlab Compiler Runtime (MCR).
This is a pre-requisite as it contains the Matlab core functionality that is required by your application and it is royalty-free.
So these are the steps you need:
In your Matlab installation, use the Matlab Compiler to generate a standalone executable of your program.
In the machine you want to deploy your application, Install the same MCR version than the Matlab version you used to generate your program.
Run the program
If you want to run a MATLAB application as stand-alone... whether it be a GUI or a script, it's not required that MATLAB be installed on your computer. You can, in fact, distribute any MATLAB application that you develop to those who don't have MATLAB installed on their computers, but you need the MATLAB Runtime libraries installed before doing so.
On the developer's end, the use of the MATLAB Compiler is required to make your MATLAB application stand-alone. You need to be cautious in that certain MATLAB functions from certain toolboxes cannot be compiled with the MATLAB Compiler if they are used as part of your MATLAB code in order to create your stand-alone application. This link from MathWorks gives a very comprehensive list of what is compatible per toolbox: http://www.mathworks.com/products/compiler/supported/compiler_support.html
On the user's end, simply get them to install the MATLAB Runtime libraries. That can be found here: http://www.mathworks.com/products/compiler/mcr/
Once the developer uses the MATLAB Compiler to create their stand-alone application and once the user installs the MATLAB Runtime libraries, then you can run any stand-alone MATLAB application. Be advised that there is no way around installing the MATLAB Runtime libraries. You need these for any MATLAB application to run stand-alone.

(Matlab) Want to create a MATLAB program that does not require Matlab to run it

Let say I wrote a program which has GUI. And I want to share with my friend who don't have MATLAB in his computer. Can I some how convert it to Java or other language? I tried using deploytool but it need the target computer install MCR in order to work.
Yes, you should use MATLAB Compiler (which deploytool is part of) to create a standalone executable from your GUI. The end-user does require the MCR (MATLAB Component Runtime) to run your compiled application, but you can freely distribute it if you have a license of MATLAB Compiler.
Note: last I looked, the application are OS-specific, i.e. if you use Windows to compile your application, you can only deploy in on a Windows platform.

does console exe files created by matlab need MCR

I wrote an application (GUI) in Matlab and I want to distribute it as a console exe file, does the user need to install MCR?
Short answer: Yes
I stole a nice answer from Matlab Central:
When using the MATLAB Compiler to compile MATLAB code into a
standalone executable, you do need to install the MCR because the
generated code calls into these runtime libraries. Also, you can
package the MCR together with the executable and have it installed
automatically when the executable is run. If you are using deploytool,
you simply need to select "Add MCR" and "Embed the MCR in the package"
from the Package pane.
Note that MATLAB Coder is the other product that actually allows you
to generate truly standalone C/C++ code from MATLAB code (without any
need for additional libraries like the MCR). However, it supports only
a limited subset of the MATLAB language.

Matlab compiler runtime library

I have developed code on a m-file script in Matlab that communicates with a Measurement Computing USB-DAQ module, and I'm quite happy with that. The problem is that I don't want to purchase another license for the computer which is running the code. I have looked into Matlab Compiler Runtime tools, and it claims that I can deploy my mcc built executables to be royalty-free. Does that mean I can install the MCRInstaller (copied from the computer in which the Matlab is installed) on the host computer running the final product?
Yes. You install the Matlab Compiler Runtime (MCR) on the host computer that will be running the executable produced by the Matlab compiler.
Yes, you can install MCR and using the Deployment Tool it's easy to create a software package with all the files you need inside.