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

backwardbackwardscompatiblecurrentdllMATLABMATLAB Compilermexcodemexfilemexglxmexsolrecompiles-function

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.

Best Answer

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
Related Question