MATLAB Compiler - matlab

I use MATLAB 2012a. I need to compile a mex file in my program. Everything works fine with Microsoft SDK 7.1 but I need a minor compiler in order to work my program in other computers. Suggested compilers on MathWorks website are compilers that need to be installed as packages. Is there any compilers that work stand-alone and don't need to be installed?

You can use MinGW, but it is not straightforward. See this Q&A. The accepted answer suggest to compile and link MEX files outside of MATLAB, which is fine, but it's simple to just create mexopts.bat to do this.
A good mexopts.bat for MING is hosted here. Pick a MINGW distribution from win-builds and set the paths in mexopts. Then you can use mex -setup with this file.
gnumex is a disaster, IMO.

Related

How to use OpenCV in Matlab?

I have looked at many resources. I just want a simple way to use the newest OpenCV with Matlab 2017a. MinGW doesn't work and a compiler but I can't seem to get Visual C++ working. I can use OpenCV in Visual Studio but what compiler does Matlab want from me and how do I obtain it?
There is a way to use opencv from matlab without compiling any mex files, and without using the computer vision toolbox.
You can call opencv through matlab via python commands.
1) Download and install the CPython distribution, not Anaconda
2) from the command prompt, install the opencv and other packages you want using the pip command > python -m pip install opencv-python
3) Follow the procedure in the matlab help for ensuring matlab knows where to look for the python installation
4) use the syntax py.cv2.function to call the opencv function
If you keep the data types as python data types in matlab while using the py.cv2 functions there isn't too much of a speed hit.
As #Miki mentions in the their comment, have you checked out this page on the MathWorks site? It has many resources, the main one is the Computer Vision System Toolbox OpenCV Interface. It comes with some examples which would be a good starting point. And if those aren't close to what you want, try another one of the community examples on the File Exchange and trying to make small changes to it.
For each version of MATLAB you can find the supported compilers in the documentation. You can also use -v flag as shown blow to see all the paths where MATLAB looks for a C++ compiler.
mex -setup -v

Can I build mex for linux on mac?

Is it possible to use MATLAB on macOS to build a mex file for running on linux (with the .mexa64 extension)? Suppose that I have an appropriate compiler such as GCC. How would I do this? I couldn't find any useful arguments in mex.
I understand building for a different platform would require a full toolchain, but I'm wondering if MATLAB has one already under the hood.

Building an entirely installation-free Windows standalone via Matlab Compiler

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.

Does MATLAB support GCC as a compiler for MEX files? Why isnt it listed on their page?

I am a total noob when it comes to compiling MEX files for MATLAB. I am thoroughly confused by the different versions of things, compilers, MATLAB versions, etc.
I have MATLAB 2013a, 64-bit, on a Windows-7 machine. I would like to add a C/C++ compiler to it, so that I can compile MEX files. This page here does not list the GCC compiler as a possible use.
However, for many files on the matlab exchange, they use GCC>= 4.2 apparently, for compiling MEX files.
So I am confused... all I want to do is run a MEX file, and install a compiler... does GCC work? If so why isnt it listed on the MATLAB page? Where do I start?...
Thanks!

How to install a compiler on Windows? (For a Matlab program)

I have downloaded this code;
http://www.cs.sfu.ca/%7Emori/research/superpixels/superpixels64.tar.gz
In the readme file, it says;
Run mex -largeArrayDims on *.c in yu_imncut directory
-largeArrayDims is needed for 64bit architectures (thanks to Richard Lowe for providing fixes for 64bit MATLAB)
Obtain mfm-pb boundary detector code from
http://www.cs.berkeley.edu/projects/vision/grouping/segbench/
Change path names in sp_demo.m and pbWrapper.m
Get a fast processor and lots of RAM
Run sp_demo.m
I tried to do the mex -.. one but it told me that I don't have any compiler. How can I fix this? Can you please help me with this? I am using 64 bit Windows 7
As far as I know GCC for Windows is not supported by Matlab. Visual Studio Express Editions will work, but 2010 may require a patch dependent on the version of Matlab you are running (http://www.mathworks.com/support/compilers/R2011a/win32.html). This page lists all supported compilers for Matlab.
Here's a link to GCC for windows
http://gcc.gnu.org/install/specific.html#windows