Creating a stand-alone application from Matlab code

I have a Matlab code and a graphical interface for it, and I want to make a standalone .exe so that it can be used on computers that do not have Matlab installed.

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

What interests me is if there are any ways to create a standalone .exe that still uses Matlab code but is not dependent on MCR. I want it to just start when you click it without requiring anything else.

I know that C can use Matlab, is there a way to use code with C? What about open source alternatives to matlab?

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

Thanks.

+4
source share
5 answers

Some time has passed since I looked at the MATLAB compiler, but if I remember correctly, it used to generate C / C ++ code, rather than compiling and generating an executable file. The toolbars your code used were always present in the hang, and whether the compiler supported them or not. Is there a chance that you can install the MATLAB application on the server and get a client phone on your desktop?

For other languages, I would check out NumPy and SciPy in combination with matplotlib (matplotlib.sf.net). I am currently working with the developer of MATLAB, and so far he is very pleased with the experience.

+1
source

MCR is required, but there is a trick: it actually does not need to be installed, just available in PATH. Launching MCR material does not require any registry entries or anything else special from the installation process. You just need readable MCR files, and the DLLs are localized by the usual search engine, which includes PATH checking at program startup.

For example, I executed compiled Matlab applications using MCR, which is “installed” on a network drive. You run the MCR installer on one computer and install it on the network drive X:\Matlab\MCR\R2010b-win32 instead of the usual location C:\Program Files . Then run your program through a shell script that adds X:\Matlab\MCR\R2010b-win32\bin\win32 to PATH before X:\Matlab\MCR\R2010b-win32\bin\win32 your actual .exe file, and will run on any other computer that sees the same drive. even if the MCR installer hasn 'They were running on them. (In the end, we stopped because downloading MCR from the network is a performance hit.)

You can use this trick to associate the MCR with your application. Attach the entire MCR installation (the tree resulting from the installation, and not the installer itself) in a subdirectory of your application directory directory and indicate that the entry point to your application is a .bat file or another shell script that indicates that the MCR is in PATH before running your MCR dependent .exe file.

Of course, consult with your legal entities to make sure that this does not violate your licensing terms.

+2
source

I have studied a little, and I'm afraid that your only option is to either use MCR or convert your code to another language. It makes sense that MathWorks wants you to use only your compiler to create .exe files.

Consider a different language only if you are already familiar with them and / or you have enough time for what you are trying to accomplish. In addition, if you use functions in Matlab that you do not write, you will also have to write those that can be very difficult / impossible.

If none of the above problems is a problem, then which language you should use is really up to you. You are not limited only to C and Python. Matlab, in my opinion, is very similar to other common languages, at least in terms of syntax. You will need to learn anyway, so I would advise you to either go to a language that you know, or choose a language for which it is easy to find help. C # and Java are two of the more well-known languages.

+1
source

MathWorks recently introduced the new MATLAB Coder . It is capable of generating C \ C ++ code from your MATLAB code (it generates source code, not executable files). The generated code is portable and independent of MCR, although it only supports a subset of the basic functions of MATLAB.

+1
source

Matlab 'compiler is not a compiler. It converts the Matlab m-code into C ++ code, and then sends it to the actual compiler, similar to the one in Visual Studio, etc. The encoding that he does is not actually human readable.

To create a stand-alone application, install the following toolbars (at any price you paid):

MATLAB Builder JA, MATLAB Builder NE, MATLAB Compiler

Configure the Matlab compiler by pointing it to the actual compiler on your disk (i.e. mbuild -setup).

Select the compiler: [1] Microsoft Visual C ++ 2008 SP1 in C: \ Program Files (x86) \ Microsoft Visual Studio 9.0

Then use (e.g. deploytool type) to make the main one and define various helper functions, etc. Split your Windows console or standalone. Then click "Create." He will make an exe file for you. You can also compile DLLs, etc. As needed.

New versions of compiler support for compiling eval, all licensed tools, and support for importing Java classes that allow you to use, for example, the DOM to parse XML files, etc.

To use the received exe file on a computer on which Matlab is not installed, you need to get Matlab MCR and install it. The MCR should exactly match the version of Matlab that you used to compile the compiled code.

Hi,

Ivan

0
source

Source: https://habr.com/ru/post/1314993/


All Articles