Clear Filters
Clear Filters

Compiling MEX-files under Windows with cross-version portability

19 views (last 30 days)
We are able to successfully compile/link MEX-files of our code for distribution under Linux, macOS, and Windows. Under Linux and macOS, there is forward and backward MATLAB version compatibility: for example, MEX-files compiled using mex under R2019b will run on a separate machine under R2023b. This is not the case, however, under Windows.
Part of the issue seems to occur when multiple versions of MATLAB are installed on the target machine: the copy of libmex.dll from another version of MATLAB might be loaded at runtime, causing a complete crash of MATLAB. (Oddly, loading the MEX-file into Dependencies caused it to crash as well.) Following from the previous example, once R2023b was removed from the machine, the MEX-file loaded/ran in MATLAB (and Dependencies).
Separately, however, it seems that there is not cross-version compatibility under Windows that we see under Linux and MATLAB. That is, MEX-files compiled under R2019b will not run on R2023b (we have not tested backward compatibility yet). We tried to link explicitly to the .lib versions of required libraries, but the .dll versions are still linked (the .lib libraries must be import libraries and not static archives?). Again we experience cross-version compatibility under Linux and macOS, and would expect any changes to available symbols in libraries like libmex.dll to be consistent for the same version of MATLAB under different platforms. Is there a known way to overcome this and is there any other information that can be shared on why we are experiencing this?
  3 Comments
Walter Roberson
Walter Roberson on 11 Nov 2023
R2017b and earlier would be expected to not be compatible with later versions, because of the change in handling complex numbers https://www.mathworks.com/help/matlab/matlab_external/matlab-support-for-interleaved-complex.html#mw_16bf50b8-39fd-4a2d-8e27-6c2661ee5bdf
But by R2019b that would be expected to be all consistent -- unless, that is, something in the toolchain was setting the flag for separate complex.
Rik
Rik on 11 Nov 2023
From my experience, there is already a fairly good portability. To be fair, this is all on the same computer, but for me the w64 works on all releases. I don't know if that is due to the specifics of this program. I must admit my experience with mex (and C in general) is mainly to hack this FEX submission together.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!