Can I configure a mex compiler on toolbox installation?
Show older comments
I have set of XML mexopts files and helper files that enable the use of the MinGW and Cygwin Fortran compilers on Windows on pre-R2024a releases. I'd like to package these in a toolbox like the compiler support package from Mathworks: https://www.mathworks.com/matlabcentral/fileexchange/52848-matlab-support-for-mingw-w64-c-c-fortran-compiler
On a fresh install of Matlab (i.e. mex not previously set up), installing that toolbox sets up the MinGW compilers. I don't see a mechanism in the toolbox packaging tool to do this, though, and the only other answers I could find on this question suggest either having a check run the first time the user executes a toolbox function or having the user run a setup function.
Is there a way to do this automatically for user-created toolboxes?
3 Comments
I've never used it so not sure if it would make it possible, but @Image Analyst posted a link to a packaging tool that has much more flexibility than the supplied tool. <Gammadyne Centurion Setup>. You might explore its possibilities or maybe @Image Analyst himself will see this and have ideas.
It would indeed be a most welcome addition to the Fortran mex world -- I gather you must have figured out how to link with the MS/Intel libraries distributed with the earlier releases. I looked at this several years ago and was never able to resolve the difference in naming conventions used by MinGW vis a vis MS and at that time at least, there was no way to cause the symbol names to have a matching decoration style. If you figured out something I didn't or MinGW changed since, that's wonderful news, indeed.
Now if only Mathworks would at least get to F95 interfaces and support, what more F2008+
F2018 (adopted Nov, 2018) is fully implemented by all major compilers.
F2023 (Nov 2023) is the current and is being implemented but probably another year or so before full compliance.
With the adoption of C interoperability in F2003 (now over 20(!!!) years ago) there's no longer an excuse to hamstring the full API mex functions.
Josh G.
on 25 Feb 2026
dpb
on 25 Feb 2026
"... I'm baffled at MathWorks' insistence that there are technical limitations preventing gfortran from working on releases prior to R2024a."
Agreed. Since gfortran is simply a frontend translator and not a full Fortran compiler, it's always been just an excuse. I wish they would just tell you the libraries and link and let one forego all the mex stuff they've hidden. Be much more simple.
It seems strange to me given the ubiquitous nature of the MS/Intel compilers that gcc doesn't have a more generic set of ptragmas to handle such-- you would have thought somebody would have found the need and added it ere now.
I last did any serious Fortran mex with CVF/DVF in support of a real time fossil power plant thermal performance code moved from VAX/VMS to OS/2 to WinNT ages ago. It's still running nearly 30 years after at the power plants; the major utility that sponsored the conversion warehoused a stash of office 386's and if one dies, they go get another. <vbg>
Answers (0)
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) 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!