Although I personally have don’t need to compile any mex files in fortran for Matlab, another scientist here at NWRA does, so I thought I was post how to get this running for anyone who is interested.
The instructions are specific to the 64-bit Matlab 2010b on Mac OS X. According to MathWorks, we need to use gfortran version 4.3.
1. Download and install Xcode 3.2 from Apple (this will give you a c compiler).
2. Download GMP version 4.3.2.
3. Download MPFR version 2.4.2.
4. Check out gcc version 4.3.4 with
svn co svn://gcc.gnu.org/svn/gcc/tags/gcc_4_3_4_release
5. Make an empty build folder for gcc, I called it “gcc-build”
6. Move both gmp and mpfr to the “gcc_4_3_4_release” folder and make sure they’re labeled exactly “gmp” and “mpfr”. At this stage I have a root folder called “gfortran” with,
7. From within the gcc-build folder run,
../gcc_4_3_4_release/configure --enable-languages=c,fortran --target=x86_64-apple-darwin -build=x86_64-apple-darwin --host=x86_64-apple-darwin
8. Compile gcc, gfortran, and the associated libraries (this will take a while),
9. Finally you can install this with,
sudo make install
From within Matlab, run “mex-setup” and choose the gcc option. At this point you should be able to compile the yprimef example code included with Matlab.