Assuring mex compatibility on different systems

Hi there,
I'm looking at creating some mex libraries that will be used by other people. I need to know what is involved with assuring compatibility across different systems. I need to have support for Linux, Windows, and Mac OS X.
In general, I understand the mex file-suffix naming conventions that represent system OS and architecture, such as .mexw32 for x86 Windows, .mexw64 for x64 Windows, mexa32, mexa64 for linux x86 and x64 respectively, mexmaci, and mexmaci64 for Mac OS x86 and x64 respectively.
However, I am unsure if there are any additional stipulations for assuring compatibility of sharing mex files to users who are using MATLAB in a variety of environments.
For example, if I build a mex on my Windows 7 x64 machine with MATLAB 2015a, will another user be able to run it just fine with Windows 10 x64 and MATLAB 2016a?
What about building on Ubuntu 16, will a user using Ubuntu 12 be able to run the mex?
So I really need to know how cross-system compatibility of pre-compiled mexed code is supported, or not?
I don't want other users to have to bother with the process of compiling my mex, and I want to provide mex files of my code that will be supported on a wide range of systems. What do I have to know to make this possible?
Thanks, Brian

 採用された回答

James Tursa
James Tursa 2016 年 8 月 11 日

0 投票

There is NO assured compatibility of compiled mex code across different versions, operating systems, or platforms. The only assured compatibility for compiled mex code is to run under the same MATLAB version on the same operating system and platform. You might be lucky and get the same mex code to run under a different MATLAB version, but it just depends on what versions are involved as to whether you will get lucky or not. Your goal of having a single mex routine that can seamlessly be run by users across different MATLAB versions etc cannot in general be realized.

7 件のコメント

Brian
Brian 2016 年 8 月 12 日
I'm sorry, I've unaccepted the answer based on finding this information
"MEX files use MATLAB runtime libraries. MEX files are usually backward compatible, which means you can run a MEX file that was created on an earlier version of MATLAB on later versions of MATLAB. If the MEX file generates errors, recompile the MEX file from the source code."
It doesn't fully disagree with your answer, but it is much less trepidacious than your feedback.
It would be really nice if the limits of "are usually backward compatible" could be explained clearly. What mex features/functions, etc can break this backward compatibility?
Walter Roberson
Walter Roberson 2016 年 8 月 12 日
What mex features/functions, etc can break this backward compatibility?
Everything except the binary structures for MAT 3.0 (-v3) and MAT 5.0 (first release) (-v5) as those have been documented; the changes to the type systems for -v7 were not documented but produce MAT 5.0 files that are typically not backwards compatible if any "new style" objects are included. The file format for -v7.3 is documented as being "similar to" HDF5 but the differences are not documented.
And that's it. Everything else is subject to change from release to release. Some of the changes only require recompilation to pick up new #define and new library code; other changes require rewriting mex code. The attribute blocks that describe variables are subject to change, including becoming larger. Officially sanctioned calls can start checking for compatibility with internal undocumented changes, including in ways that force use of new undocumented calls for code that used to work.
Everything that is not explicitly documented as working under particular circumstances will eventually break without notice. Everything that is explicitly documented as working under particular circumstances may eventually break suddenly with notice in the release notes.
Brian
Brian 2016 年 8 月 13 日
I appreciate your time taken to expand on this.
In regard to the types of changes you describe, it sounds as if they encompass incremental modifications to handle newer features/requirements. Is it then generally safe to build on an older system, say 2010, and test compatibility on 2016, and if this works would it be fairly certain to work on all releases in other versions between the build and testing systems?
Matt J
Matt J 2018 年 4 月 26 日
編集済み: Matt J 2018 年 4 月 26 日
There is NO assured compatibility of compiled mex code across different versions, operating systems, or platforms.
But per the OPs question, are Windows 7 x64 and Windows 10 x64 to be considered different operating systems/platforms? Seemingly not, according to this platform compatibility doc. The mexext is all that matters.
Walter Roberson
Walter Roberson 2018 年 4 月 26 日
There have been known to be version-specific issues, so the fact that a mex works with 2010 and with 2016 does not mean it will work with all the versions between.
Matt J
Matt J 2018 年 4 月 27 日
version-specific issues perhaps, but platform-specific issues?
Walter Roberson
Walter Roberson 2018 年 4 月 27 日
I was responding to Brian's question about "Is it then generally safe"

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

製品

質問済み:

2016 年 8 月 10 日

コメント済み:

2018 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by