MATLAB Compiler Runtime - how to run it? - matlab

I'm supposed to install the MATLAB compiler runtime for class purposes in one of my subjects at University. I have installed it and followed the guide - and this is my silly question: How do I run it? I mean, shouldn't there be some sort of icon or file I need to click to run the actual program?
It shows up on my list of installed programs (under controlpanel -> programs and features), and I have checked the folders where i installed it, but there doesn't seem to be any file or anything I can use to actually run it.
Maybe I misunderstood the purpose of MCR, but any help would be greatly appreciated.
Also, note that I am still new to anything computer-related that is more advanced than basic HTML and opening zipped files.

This question was already correctly answered in the comments by #seb, but to make sure it does not remain open I will post the answer here:
You need to write Matlab code and generate a .dll (or executable
maybe). Then this .dll can be run on a PC that has either Matlab or
MCR installed. But you don't click and start MCR.
And in addition to that I have added a description of how I see the MCR:
Think of the MCR as a bundle of complicated functions. When you compile a program you will just have the references to those functions in your program. Most of the content will actually be drawn from the MCR when your program is run.
That being said, if you actually want students to work with matlab (not just with programs pre built by the teacher) you will actually need to install Matlab, and not the MCR.

Related

SDL.h "Program file does not exist"

I'm pretty new to c++ (and programming in general) and I'm currently trying to inlcude the "SDL.h" header into a c++ project in Eclipse (I use minGW btw). I've provided the project with the paths to the the header files and the library of SDL. However, whenver I specifically include "SDL.h" and the build then project I get the following Message:
" 'Launching SDL Basic.exe' has encountered a problem. Program file does not exist. "
I'm pretty sure that this has to do with the fact that no .exe file is generated whenever I build the project with SDL.h included. What I don't get is why this happens. When I include some other SDL header, such as SDL_assert, this is not a problem. Then the .exe file is generated just as usual and the program runs just as it should.[enter image description here][1]
http://i.stack.imgur.com/cdV8U.jpg How it looks when SDL.h is included.
http://i.stack.imgur.com/MW7PX.jpg How it looks when something else from SDL is included.
I seem to have fixed the problem. Whenever I ran the program the console window outout " undefined reference to 'Winmain#16' ". So I googled on it and found out that SDL defines its own main function in SDL_main.h, which in total would give me two main functions. To prevent SDL from defining its own main function I had to define the macro SDL_MAIN_HANDLED before I included SDL.h, and look, it worked:
http://i.stack.imgur.com/mNOOE.jpg
If someone can explain this in more detail I'd really appreciate it.
I did a little research and it looks like the undefined reference to WinMain#16 is because SDL is automatically creating a Windows entry point for your application, but you haven't provided the necessary libraries to link in the SDL implementation of that entry point. However, if you intend to use the SDL functionality, you really do need that entry point, because it performs several important initialization steps necessary to leverage the SDL features that you presumably want to use.
Defining SDL_MAIN_HANDLED is a mechanism that would allow you to provide your own Windows entry point (i.e.: WinMain), but that is a more complicated approach (albeit more flexible). This only solves your problem because it happens to prevent "main" from being redefined to "SDL_main" which in turn means that your .cpp file no longer even requires any of the SDL libraries. So it compiles and links, but you won't have any of the SDL functionality you're looking for.
You need to link in the appropriate libraries. See here - it provides some info that might help.

Structure of lisp projects

When I use Eclipse or Visual Studio or Xcode, structure of the project gets created automatically and one can get started immediately.
Now I am trying to create a project on Allegro CL express edition and if I collect all lisp files and run it, it shows package errors which I believe is because of files not getting executed in a specific order as packages must be created in some file that must be executed first.
I am not able to understand how to approach this problem. There is no or little information on creating large projects in lisp and how to incrementally deal with its size and complexity.
I want to port Maxima onto Allegro CL. Can I get some help here and also if one can explain this break up of code in multiple files and packages and basically how to load the whole system.
I know basics of lisp but I don't understand lisp project's structure.
Good news: Maxima already has an Allegro port. You should be able to build it using ./configure --with-acl then type make. I haven't used this recently, but I would expect this to work.
If you want to know more about how stuff is loaded, look at src/maxima.system. It's a bit archaic because it is written for defsystem, which has now been replaced pretty much everywhere else by asdf.
Well, Maxima can be compiled via defsystem or asdf by several Lisps, including Allegro. See INSTALL.lisp for details.
The only limitation that I know of is that the Allegro Express version cannot compile the SLATEC-derived code (the functions translated from Fortran are too big or something like that). So you will have to comment out the SLATEC stuff in maxima.system or maxima.asd.

Is it possible to compile Matlab code into a stand alone exe?

Is it possible to compile Matlab code into a stand alone exe? meaning being able to run the program without having to have matlab or the matlab runtime environment installed on the computer?
does it help that the code has no GUI and does not use any toolboxes? also, the only interaction the person has with the code is through the command prompt
You need MATLAB Coder to generate C/C++ code from your MATLAB code. Yes, it does help that you don't have any GUI. Your code also needs to be restricted to the subset of MATLAB language that is supported by code generation. As far as toolboxes are concerned, there are quite a few which are supported by code generation.
A few people have mentioned the MATLAB Compiler. This is indeed for deployment on a machine where the end user does not have MATLAB, but it does require the installation of the runtime environment (MCR or MATLAB Component Runtime), which is freely distributable if you have a license of MATLAB Compiler. This does allow you to compile GUIs, but anything that is compiled on Windows can only be deployed on Windows, Linux on Linux, etc... (unless things have changed since I last used it).

MATLAB compiler - preserving source code

I have a question about Matlab compiler, which I am very new to.
I am trying to compile a large Matlab program to a standalone unix application. It has a number of supporting directories (filled with .m files) which run algorithms on input data. One of the key uses of this program is in allowing users to add their own .m files with their own algorithms for the program to run.
I am able to compile the project and run it as a standalone without issue. But the user can no longer access and add supporting files once it had been compiled.
Has anyone ever come across this before and have any suggestions for dealing with it? I understand that the .m files need to be compiled to .exe and such, but I was hoping Matlab might have a workaround for keeping supporting files in their original state.
This behaviour is by design, and you can't get round it - in fact it's not only technically impossible, it's against the license agreement:
5.2.3. Licensee's Application may not provide scripting capability
similar to the capabilities of any of the Programs or provide
functionality or behavior similar to that of the MATLAB command
line.
Imagine if you created an application that simply accepted user input and passed it into the function eval. If you compiled it, you would then be able to essentially give away free copies of the whole of MATLAB to anyone.

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.
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.
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.
MathWorks recently introduced a new product MATLAB Coder. It is capable of generating C\C++ code from your MATLAB code (generates source code not executables). The generated code is portable and does not depend on the MCR, though it only supports a subset of core MATLAB language features.
I have researched a bit, and I am afraid that your only option is either using the MCR, or converting your code into another language. It makes sense that MathWorks would want you to use only their compiler in order to create .exe files.
Consider another language only if you are already familiar with them, and/or you have enough time for what you are trying to accomplish. Furthermore, if you are using functions in Matlab that you didn't write, then you will have to write those also, which may be very hard/impossible.
If none of the above is a problem, then what language you should use is really up to you. You are not just limited to C and Python. Matlab, im my opinion, is very much like other common languages, at least in terms of syntax. You will have to do some learning either way, so I would suggest that you either go with a language you know, or pick a language for which finding help is easy. C# and Java are two of the more 'famous' languages.
The Matlab 'compiler' is not a compiler. It translates Matlab m-code into C++ code and then sends that to an actual compiler like the one in Visual Studio, etc. The code it makes is not really human-readable.
To make a standalone app, install the following toolboxes (at whatever price you paid):
MATLAB Builder JA, MATLAB Builder NE, MATLAB Compiler
Set up the Matlab compiler by pointing it to the actual compiler on your drive (i.e. mbuild -setup).
Select a compiler:
[1] Microsoft Visual C++ 2008 SP1 in C:\Program Files (x86)\Microsoft Visual Studio 9.0
Then use the (i.e. type deploytool) to make the main and to define various helper functions etc. Sect windows console or standalone. Then click build. It will make the exe-file for you. You can also compile to DLL, etc as needed.
Newer versions of the 'compiler' support compiling of eval, all toolboxes that are licensed, and it supports import of java classes that will allow you to use for example, a DOM for xml-file parsing etc.
To use the resulting exe-file on a computer that does not have Matlab installed on it, you need to obtain the Matlab MCR and install it. The MCR must match exactly the version of Matlab you used to make the compiled code.
Regards,
Ivan