mex -setup doesn't find the compiler gfortran

2 views (last 30 days)
I am having trouble using mex with Matlab. I am following these steps to try to use mex: http://www.mathworks.com/support/tech-notes/1600/1605.html#setup . Things go wrong with the very first step- the command mex -setup. This command is supposed to find all supported compilers (<http://www.mathworks.com/support/compilers/R2012a/glnxa64.html>) and let you select the one that mex should use in the future. When I run this command, Matlab does not find gfortran. I thought that it might be a path issue (see http://www.mathworks.com/matlabcentral/newsreader/view_thread/172171) I checked my gfortran location against the paths that Matlab checks for the compiler (by running the command getenv('PATH')). I also added the paths to my list of paths in startup.m to be extra sure. I also found that I was using a higher version of the gcc compiler than was supported by Matlab so I downgraded the compiler to the specific version of gfortran on the supported compilers list. None of these things solved the problem. Can you suggest anything? I am using the release R2011b.

Accepted Answer

Ken Atwell
Ken Atwell on 31 Mar 2012
Elizabeth,
If gfortran is on your PATH, MATLAB should be able to find it. Run "mex -setup" and just pick the only option available to you (gcc).
Then, "mex -v filename.f". -v is for verbose. If this fails to build because MEX cannot find the gfortran, post the entire verbose output to this question to help us troubleshoot this problem.
  2 Comments
Robert
Robert on 19 Feb 2014
gfortran works from Terminal on MacOS
( which gfortran
/usr/local/bin/gfortran
)
but doesn't from inside MATLAB
mex -v timestwo.F
**************************************************************************
Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require
the use of -largeArrayDims and remove the -compatibleArrayDims
option. For more information, see:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
**************************************************************************
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
FILE = /Users/murphy/.matlab/R2013a/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2013a.app
-> CC = xcrun -sdk macosx10.7 clang
-> CC flags:
CFLAGS = -fno-common -arch x86_64 -isysroot -mmacosx-version-min=10.7 -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = xcrun -sdk macosx10.7 clang++
-> CXX flags:
CXXFLAGS = -fno-common -fexceptions -arch x86_64 -isysroot -mmacosx-version-min=10.7
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
FFLAGS = -fexceptions -m64 -fbackslash
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = xcrun -sdk macosx10.7 clang
-> Link flags:
LDFLAGS = -arch x86_64 -Wl,-syslibroot, -mmacosx-version-min=10.7 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013a.app/extern/lib/maci64/fexport.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmaci64
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------
-> gfortran -c -I/Applications/MATLAB_R2013a.app/extern/include -I/Applications/MATLAB_R2013a.app/simulink/include -fexceptions -m64 -fbackslash -DMX_COMPAT_32 -O "timestwo.F"
/Applications/MATLAB_R2013a.app/bin/mex: line 1343: gfortran: command not found
mex: compile of ' "timestwo.F"' failed.
Error using mex (line 206)
Unable to complete successfully.
Ken Atwell
Ken Atwell on 19 Feb 2014
Robert, you may want to start a new topic to get more exposure -- this thread is nearly two years old.

Sign in to comment.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!