Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a standalone app from Matlab code

I have some Matlab code and a GUI for it and I want to make a standalone .exe so that it can be used on computers that don't have Matlab installed.

I know about the Matlab compiler and how to use it, but that creates an .exe that only works if the user has the MATLAB Compiler Run-Time (MCR) installed.

What I'm interested in, is if there are any ways to create a standalone .exe that still uses the Matlab code but does not depend on the MCR. I want it to just run when you click it without needing anything else installed.

I know C can make use of Matlab, is there any way to use the code with C? How about any open source Matlab alternatives that can it?

As a last resort, if I were to rewrite the Matlab code in another language, what language would you recommend? I was thinking C or Python.

Thanks.

like image 292
user384918 Avatar asked Jul 07 '10 20:07

user384918


2 Answers

It's been a while since I looked at the MATLAB compiler but if I remember correctly it used to be able to generate C/C++ code rather than going all-out and generating an executable. The hangup was always in which toolboxes your code used and whether the compiler supported them or not. Any chance you could install the MATLAB application on a server and have a desktop client phone in for results?

As far as other languages go, I'd check out NumPy and SciPy in combination with matplotlib (matplotlib.sf.net). I'm working with a MATLAB developer right now and so far he's pretty pleased with the experience.

like image 128
ChrisC Avatar answered Sep 30 '22 12:09

ChrisC


The MCR is required, but there's a trick: it doesn't actually have to be installed, just available on the PATH. Running MCR stuff doesn't require any registry entries or anything else special from the installation process. You just need the MCR files readable and the DLLs locatable by the normal lookup mechanism, which includes checking the PATH at the time of program launch.

For example, I've run compiled Matlab apps using an MCR that's "installed" on a network drive. You run the MCR installer on one machine and have it install to network drive X:\Matlab\MCR\R2010b-win32 instead of the usual C:\Program Files location. Then have your program be launched through a wrapper script that adds X:\Matlab\MCR\R2010b-win32\bin\win32 to the PATH before calling your actual .exe file, and it'll run on any other machine that sees the same drive, even if the MCR installer hasn't been run on them. (Eventually we stopped because loading the MCR from the network is a performance hit.)

You could use this trick to bundle the MCR with your application. Stick the whole MCR installation (the dir tree resulting from installation, not the installer program itself) in a subdirectory of your application's directory tree, and have the entry point to your app be a .bat file or other wrapper script that sticks that MCR dir on the PATH before running your MCR-dependent .exe file.

Of course, check with your legal folks to make sure this doesn't violate your licensing terms.

like image 25
Andrew Janke Avatar answered Sep 30 '22 13:09

Andrew Janke