From: Robert on
If I call "mex hello.f", I get the message:
/Applications/MATLAB_R2009aSV.app/bin/mex: line 992: gfortran: command not found

However, I can use gfortran to compile functions from the command line.

Any idea what the problem is? Does mex have its own path variable?
My gfortran is located at /usr/local/bin/gfortran

I'm running Matlab R2009a on my mac x86 with OS 10.6.
From: Dave on
I had a similar problem until I hard-coded the gfortran path as below. This was for R2009b/64-bit, but a similar solution may work for your.

Dave


% Compiler settings for R2009b 64-bit Mac OS X: %
-----gfortran:-----
I used this version http://r.research.att.com/gfortran-4.2.3.dmg instead of the experimental version for Xcode 3.2.

-----Xcode:-----
http://developer.apple.com/technology/xcode.html


-----Matlab Mex options:-----
Here's the modificatins to the maci64 section from my 'mexopts.sh' file. There was a problem with it using the wrong libgfortranbegin when building a 64-bit mex until I hard-coded the correct path. BTW, you may want to clear out the '/usr/local/lib/' directories before re-installing gfortran.

# To use the gfortran compiler, which must be installed separately,
# include the following modifications to the 'maci64' section of the
# '~/.matlab/R2009b/mexopts.sh' file

# -----Modifications by D.Jones, Sep-2009:--------------------
FC='/usr/local/bin/gfortran'
FC_LIBDIR='/usr/local/lib/'
FC_LIBDIR2='/usr/local/lib/gcc/i686-apple-darwin8/4.2.3/x86_64/'
FOPTIMFLAGS='-O5 -funroll-loops -ftree-vectorize'
# ------------------------------------------------------------

# Note that gfortran installs its libraries in ‘/usr/local/lib/’
From: Darwin on
Robert,
Did you run mex -setup and choose the fortran compiler?
Darwin

"Robert " <llmmnnoopp(a)hotmail.com> wrote in message <hli0b9$6kk$1(a)fred.mathworks.com>...
> If I call "mex hello.f", I get the message:
> /Applications/MATLAB_R2009aSV.app/bin/mex: line 992: gfortran: command not found
>
> However, I can use gfortran to compile functions from the command line.
>
> Any idea what the problem is? Does mex have its own path variable?
> My gfortran is located at /usr/local/bin/gfortran
>
> I'm running Matlab R2009a on my mac x86 with OS 10.6.
From: Rune Allnor on
On 18 Feb, 01:07, "Robert " <llmmnno...(a)hotmail.com> wrote:
> If I call "mex hello.f", I get the message:
> /Applications/MATLAB_R2009aSV.app/bin/mex: line 992: gfortran: command not found
>
> However, I can use gfortran to compile functions from the command line.
>
> Any idea what the problem is?  Does mex have its own path variable?

No, but you need to set up the internal matlab environment
variables to recognize the compiler. You do that by using the

mex -setup

command from the matlab command prompt, *provided* matlab
has already been set up to recognize the compiler.

Be aware that the -setup option only works for a number
of pre-selected compilers, so there might be more hacking
required.

Rune
From: Robert on
If I run mex -setup, I get only two options. Choosing either one gives the same error reported above.

I'll try Dave's hack.