Info

This question is closed. Reopen it to edit or answer.

Problem with mex setup on mac os x with 2015a?

1 view (last 30 days)
Philip Usher
Philip Usher on 6 Apr 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
When I try to run mex -setup FORTRAN -v to set up the fortran compiler for mex. It says it can't find the gfortran library, the result for that code is:
Verbose mode is on.
... Looking for compiler 'gfortran' ...
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'which gfortran' ...Yes ('/usr/local/bin/gfortran').
... Looking for folder '/usr/local/bin' ...Yes.
... Executing command 'which gfortran' ...Yes ('/usr/local/bin/gfortran').
... Executing command '/usr/local/bin/gfortran -print-file-name=libgfortran.dylib' ...Yes ('libgfortran.dylib').
... Looking for folder 'libgfortran.dylib' ...No.
Did not find installed compiler 'gfortran'.
... Looking for compiler 'Intel Fortran' ...
... Looking for environment variable 'IFORT_COMPILER14' ...No.
... Looking for environment variable 'IFORT_COMPILER13' ...No.
... Executing command 'which ifort' ...No.
Did not find installed compiler 'Intel Fortran'.
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2015a/maci64.html.
I have tried editing the path as per this question however my system does find the gfortran it just seems to get confused with the "... Looking for folder 'libgfortran.dylib' ...No." section. Can anyone help get mex working on my system.

Answers (2)

Geoff Hayes
Geoff Hayes on 7 Apr 2015
Philip - did you try running the following (or something similar) before doing the above
setenv('PATH', [getenv('PATH') ':/usr/local/gfortran/bin']);
I had to do this before selecting the gfortran compiler (running R2014a on 10.8.5).
  1 Comment
Philip Usher
Philip Usher on 7 Apr 2015
Yes I tried that. And with the path /usr/local/bin as that is where my gfortran is.
Any other suggestions? As the output from mex -setup above shows I think it's something to do with libgfortran.dylib. So I also tried setting the dyld_library_path to the libraries that come with matlab.

Philip Usher
Philip Usher on 7 Apr 2015
Hi managed to fix my problem by adding /usr/local/lib to my dyld_library_path and creating a symylink from the libgfortran.3.dylib to libgfortran.dylib
To get the actually code to compile I also edited the mexopts.sh file. I changed the fortran related flags to the following, which is mainly based of those used for the glnxa64 architecture minus any flags that my set up didn't recognise. Here is the stuff i changed in the maci64 part of the file.
# FortrankeyManufacturer: GNU
# FortrankeyLanguage: Fortran
# FortrankeyVersion:
# FortrankeyLinkerName: GNU ld
# FortrankeyLinkerVersion:
#
FC='gfortran'
FFLAGS='-fexceptions -fbackslash'
FFLAGS="$FFLAGS -fPIC -fno-omit-frame-pointer"
FLIBS="$RPATH $MLIBS -lm"
FOPTIMFLAGS='-O'
FDEBUGFLAGS='-g'
#
LD="$COMPILER"
LDEXTENSION='.mexa64'
LDFLAGS="-pthread -shared -Wl,$TMW_ROOT/extern/lib/$Arch/$MAPFILE"
LDOPTIMFLAGS='-O'
LDDEBUGFLAGS='-g'
#
POSTLINK_CMDS=':'
Hope this helps anyone else in a similar situation or me when I have to google this problem again. But not entirely sure whether what I have done is correct.

Community Treasure Hunt

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

Start Hunting!