Use mex from Matlab R2012a in Matlab 2019

5 visualizaciones (últimos 30 días)
Roman
Roman el 4 de Oct. de 2020
Respondida: Walter Roberson el 7 de Oct. de 2020
Hi,
We have mex files running in Matlab R2012
Can I use them for Matlab 2019? If not, what should I do?
Thank you,
Roman

Respuestas (2)

Priysha LNU
Priysha LNU el 7 de Oct. de 2020
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
DISCLAIMER: These are my own views and in no way depict those of MathWorks.

Walter Roberson
Walter Roberson el 7 de Oct. de 2020
There was an internal change in .mex* files in R2011a or so, just before your R2012a, so you escape that particular problem.
Back in the R2012a time frame, it was still possible to compile for small array sizes using a backwards compatability flag. If that was done, then you cannot use the mex in current versions.
If the mex was compiled for 32 bits then the last release you can use it with is R2015a.
R2018a or so redefined the header for variables. There was a change in how complex variables are stored, but that change affected all variables. I am not certain whether old mex files are backwards compatible. As there was not a big outcry from people complaining about accessing old mex, I suspect that it does work... but I am not positive.
That said... I have seen other posts indicating that mex as old as yours are not accepted by current MATLAB, and have encountered that myself from time to time; I am not clear as to what the trigger is for that.
I have found the sufficiently old .mexmaci64 do not work with recent MATLAB versions.
So... there is a possibility it will work, but no guarantee. If it is going fail it will likely fail in a pretty obvious way, so it is worth trying.

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by