mex cannot find gfortran compiler (Mac OS)

3 visualizaciones (últimos 30 días)
Robert
Robert el 20 de Feb. de 2014
Respondida: Zhong Hao el 29 de Mayo de 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.

Respuestas (2)

Ken Atwell
Ken Atwell el 24 de Feb. de 2014
The PATH as set by the Terminal application may be different than as set by launch an application from the Dock. Try this in MATLAB:
getenv('PATH')
Is /usr/local/bin there?
Now try launching MATLAB from the Terminal window (where gfortran is on the path):
/Applications/MATLAB_R2013a.app/bin/matlab
My guess is that MEX will work if you launch MATLAB this second way.
  2 comentarios
Robert
Robert el 25 de Feb. de 2014
Thanks, that helped. I put
setenv('PATH', [getenv('PATH') ':/usr/local/bin']);
into startup.m. However, now I get
>> getenv('PATH')
ans =
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
>> 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/usr/local/gfortran/lib/gcc/x86_64-apple-darwin13/4.8.2/../../.. -lgfortran -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin13/4.8.2 -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"
-> xcrun -sdk macosx10.7 clang -O -arch x86_64 -Wl,-syslibroot, -mmacosx-version-min=10.7 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013a.app/extern/lib/maci64/fexport.map -o "timestwo.mexmaci64" timestwo.o -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin13/4.8.2/../../.. -lgfortran -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin13/4.8.2 -lgfortranbegin
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang", not a developer tool or in PATH
mex: link of ' "timestwo.mexmaci64"' failed.
Error using mex (line 206)
Unable to complete successfully.
Ken Atwell
Ken Atwell el 25 de Feb. de 2014
This is almost certainly an unrelated problem with Xcode 5 no longer shipping the 10.7 SDK (R2013a was released before Xcode 5). For a work-around, see:

Iniciar sesión para comentar.


Zhong Hao
Zhong Hao el 29 de Mayo de 2014
Upon setenv('PATH', [getenv('PATH') ':/usr/local/bin']);
I managed to successfully compile timestwo.F
However I got an error while trying to compile yprimefg.F
****************************************************************************************
>> mex -v yprimefg.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/techdoc/matlab_external/bsflnue-1.html
**************************************************************************
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
FILE = /Users/neozhonghao/.matlab/R2012a/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2012a.app
-> CC = llvm-gcc
-> CC flags:
CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/ -mmacosx-version-min=10.5 -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = llvm-g++
-> CXX flags:
CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/ -mmacosx-version-min=10.5
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB_R2012a.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_R2012a.app/bin/maci64 -lmx -lmex -lmat -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin13/4.9.0/../../.. -lgfortran -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin13/4.9.0 -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = llvm-gcc
-> Link flags:
LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/ -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2012a.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_R2012a.app/extern/include -I/Applications/MATLAB_R2012a.app/simulink/include -fexceptions -m64 -fbackslash -DMX_COMPAT_32 -O "yprimefg.F"
-> llvm-gcc -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/ -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2012a.app/extern/lib/maci64/fexport.map -o "yprimefg.mexmaci64" yprimefg.o -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin13/4.9.0/../../.. -lgfortran -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin13/4.9.0 -lgfortranbegin
Undefined symbols for architecture x86_64:
"_yprime_", referenced from:
_mexfunction_ in yprimefg.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
mex: link of ' "yprimefg.mexmaci64"' failed.
Error using mex (line 206)
Unable to complete successfully.

Categorías

Más información sobre Get Started with MATLAB Compiler SDK en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by