- https://www.mathworks.com/help/releases/R2025a/matlab/matlab_external/before-you-run-a-mex-file.html
- https://www.mathworks.com/help/releases/R2025a/matlab/ref/mexext.html
- https://www.mathworks.com/matlabcentral/answers/451281-mex-for-different-platforms-deployment-question
Question on gihub file and file exchange involving Mex files and git submodule in Matlab Project
16 views (last 30 days)
Show older comments
I am working on a TOML parser based on Tomlplusplus: https://github.com/sylvanoMTL/Matlab-tomlplusplus
The github works on by compiling mex functions. that are calling routines from the git submodule tomlplusplus.
Should I add the compiled mex files (win64) to the project? are these mex file reusable by other Win64 machines?
Do I need to compile mex files for unix/mac? and can I do that using my computer win64?
In that way the user won't have to recompile the mex functions. but I have the feel it is machine dependent.
0 Comments
Answers (1)
Abhipsa
on 7 Nov 2025 at 10:28
I would like to answer ypur questions seprately:
1. “Should I add compiled .mexw64 to the project? Are they reusable?”
Yes. They should run on other Win64 machines with a compatible MATLAB release and the right MSVC runtime. They are not tied to your machine, but they are tied to OS/arch/release/compiler.
2. “Do I need to compile for Unix/mac?”
If you want out-of-the-box support there, yes you can provide .mexa64 and .mexmaci64 too. Otherwise, ship sources and a build script so those users can mex locally.
3. “Can I build mac/linux MEX from my Windows box?”
No. MATLAB MEX doesn’t support cross-compiling between OSes; build natively on each platform (or use CI runners for each OS)
You can refer to the following MATLAB documentations and forum links for more details:
I hope this resolves your query
0 Comments
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!