Is it possible to use my old MEX-files with the current version of MATLAB?

25 views (last 30 days)
I have a MEX-file that was created in a previous version of MATLAB, and I would like to use it with the current version of MATLAB.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 15 Jan 2019
MEX-files generated with one release of MATLAB are not guaranteed (or expected) to work with a different release of MATLAB. This is due to changes that may occur in the MEX-file libraries between releases of MATLAB.
If you have the original C or Fortran code for the MEX-file, you can recompile your code using the current version of MATLAB to produce a new MEX-file for use with that version of MATLAB. This can be done using the MEX function as follows:
mex myMexFile.c
By using a version of the MATLAB Compiler prior to MATLAB Compiler 4 (R14), MEX-files could also have been created from MATLAB code with the following syntax:
mcc -x myMFile.m
For these types of MEX-files, you will need to manually adapt your MATLAB code into C-code to be compiled via the MEX command. This is because the ability of the MATLAB Compiler to compile MATLAB files into MEX-files has been deprecated as of MATLAB 7.0 (R14).
mex myMexFileAdaptedFromMyMFile.c

More Answers (0)

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!