2) I have a Fortran compiler, but it is not supported by The MathWorks. Can I still use it to compile FMEX files?
Definitely maybe. 🙂 Many people have tried over the years to use ‘non-supported’ compilers for the creation of FMEX files with varying levels of success.
Win32 (Windows 9x, 2000, ME, XP)
For Win32 platforms, the most popular alternatives are GNU g77 and Microsoft Fortran Powerstation (FPS), however, it has now been brought to my attention that the Lahey Fortran Compilers definitely can make MEX files.
Lahey/Fujitsu F95: According to this page, the Lahey F95 compiler can make MEX files with the help of the files provided at that same site. I don’t have Lahey, so I haven’t tried this myself, but if they say it works, who am I to doubt them?
GNU g77: There is a page dedicated to getting the GNU gcc compiler suite installed here. Within gcc is the g77 compiler. My guess is that with some tinkering, it wouldn’t be difficult at all to make the gcc install the page outlines call g77 instead of gcc. However, I’ve not tinkered with it. If you would be interested in trying to get it to work, I’d be happy to assist you. Drop me a note.
Microsoft FPS: This is a pretty popular one to try, too. MS FPS was the only supported FORTRAN compiler for Windows for quite a while. As a testament to this, when MATLAB calls the compiler to create a MEX file, it still uses FPS command line syntax. (DVF6.1A and MATLAB 5.3) This makes me believe that using FPS would be nearly trivial. All you should need to do is use mex -setup, choose to manually install the compiler, and choose Digital Visual Fortran. Then you will need to open the mexopts.bat file that ML has created. You can do this by searching for mexopts.bat using the search function in the file explorer. Open it in notepad (right click & choose edit). You will need to update the lines under the title “General Parameters” to point at your compiler & the correct library & include folders.
NAG: The NAG compiler is also capable of making MEX files on Linux. Seehttp://www.nag.co.uk/nagware/np/doc/linux_gateways.html for more details.
Intel: The Intel Fortran compiler can also make mex files. The instructions are at currently contained in the hints file for matlab2fmex.This is a particularly attractive option because the Intel x86 Linux compiler is free for non-commercial and academic uses, see this page.
I know that this is sparse, and I hope that the information here will grow. You can help. If you successfully get ML working with an alternate compiler, drop me an email about what you did, and please attach your mexopts.bat file.