Can I use Matlab Coder generated Mex functions on another computer

4 views (last 30 days)
I've been able to use Matlab Coder to generate Mex Functions that work on my computer; but I cannot find any instructions on how to use these Mex functions on other computers that have Matlab (and that don't have Matlab Coder). Is there a straight forward way to move the c-code it generates to another system to create the mex function?

Accepted Answer

Ryan Livingston
Ryan Livingston on 5 May 2014
To run a MEX function generated by MATLAB Coder™, you must have licenses for all the toolboxes that the MEX function requires. For example, if you generate a MEX function from a MATLAB algorithm that uses a Computer Vision System Toolbox™ function or System object, to run the MEX function, you must have a Computer Vision System Toolbox license.
The other computer should also match the architecture of the computer on which the MEX function was generated.
Are you having any specific issues when you try to run the MEX function on another machine?
  3 Comments
Fred Smith
Fred Smith on 6 May 2014
The generated MEX function relies on DLLs present in MATLAB. Those DLLs are forward (but not backward) compatible.
Therefore, the MATLAB you are running the generated MEX-function inside needs the same version or a newer version than the version you generated the MEX-function on.
You can create a MEX-function for an earlier version of MATLAB but it is a lot more work. First generate code for a static library. Standalone code (any of the non-MEX targets) generally do not rely on MATLAB's DLLs. Of course, they don't interact with the MATLAB environment at all.
Once you have a standalone library, write your own C MEX entry point by hand that calls the static library. Use the MEX command to create a MEX-function.
Another possibility is to generate a DLL and try loadLibrary. Depending on the nature of the arguments being passed in and out this may work fine.
Ryan Livingston
Ryan Livingston on 7 May 2014
Edited: Ryan Livingston on 7 May 2014
Most licenses permit you to download and install older versions of MATLAB as well. It may be simplest to generate the MEX function using R2013a assuming that R2013a has the features you require.
Instructions on installing an older version:

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!