MATLAB Answers

Does MEX compiler (and the associated shared files) automatically ship with all MATLAB distributions of any license type?

조회 수: 20(최근 30일)
A King
A King 28 Dec 2020
댓글: A King 28 Dec 2020
When creating a mex file, I see many dependencies on other (MATLAB) shared files buried in it. The question is, if I take this compiled file to another system (of the same architecture) with some random MATLAB license, are all of these dependency files guaranteed to exist in that particular installation of MATLAB? Is there a particular license that would not have mex dependency files?

  댓글 수: 5

표시 이전 댓글 수: 2
A King
A King 28 Dec 2020
James, Walter, thanks for your response. I am creating a mex shared file that I will load and use from within the MATLAB session. But I see many depdencies inside the shared file to other MATLAB shared files. and as James said, these could sources of potential conflicts with other MATLAB version. SO, A BETTER QUESTION TO ASK is: Is there a way to staticly link the generated Mex files with all of these dependencies? Another option would be to copy them all and carry them around with the mex file.
James Tursa
James Tursa 28 Dec 2020
"Is there a way to staticly link the generated Mex files with all of these dependencies?"
No, at least not in the sense that I think you are asking. The internal storage mechanisms for MATLAB variables (called an mxArray in C/C++ lingo) routinely change from MATLAB version to MATLAB version. Something as simple as getting the dimensions of a variable would look in different places in the mxArray depending on the MATLAB version. The technique for figuring out whether a variable is complex or not totally changed in R2018a (checking the Pi pointer field vs checking a bit in the flags field). All of those background library dependencies that do this in the original version wouldn't even make sense if they were running in the wrong version of MATLAB. At some point there would need to be an interface to convert from one mxArray definition to the other in order to input or output variables to/from the mex routine ... and there isn't any such interface.
Bottom line is that the mex routine compiled in one MATLAB version may or may not work in another MATLAB version. The only guarantee that you have is it will work if you recompile the mex routine in the other version.
A King
A King 28 Dec 2020
Interesting. That's good know. I guess the only way to ensure compatibility is to just use it with different MATLAB versions.

댓글을 달려면 로그인하십시오.

채택된 답변

James Tursa
James Tursa 28 Dec 2020
Mex routines are not guaranteed to be compatible between different versions of MATLAB, for the very dependency reasons you already mention. You are probably going to be OK with same MATLAB version on same architecture. But anything other than that will just depend on the particulars and can't be guaranteed. Some mex routines will run fine on several versions of MATLAB. Others will not. And, of course, if the mex routine makes callbacks into MATLAB for specific functions then that would be another source of potential incompatibility.

  댓글 수: 1

A King
A King 28 Dec 2020
James, thank you. Do you know if it possible to staticly links all mex dependencies via the MEX compiler flags? Does matlab also provide the archive versions of their shared libraries? or is dynamic linking the only possiblity?

댓글을 달려면 로그인하십시오.

추가 답변(0개)

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by