Gfortran not found by mex -setup

조회 수: 13 (최근 30일)
jg614
jg614 2019년 2월 18일
댓글: af11111 2020년 11월 10일
I'm trying to set up mex compilers on R2016b. I have GCC 8.2.0 installed (same version for gcc-c++ and gfortran). I was able to set up the GCC C and C++ compilers without a problem. When I try mex -setup FORTRAN I get an error:
Error using mex
No supported compiler or SDK was found. For options, visit
http://www.mathworks.com/support/compilers/R2016b/glnxa64.html.
But gfortran is definitely there:
system('which gfortran')
/usr/bin/gfortran
ans =
0
I understand that this is several versions newer than the officially supported version, but in my experience MATLAB usually just gives you a warning about using an unsupported version of the compiler rather than flat-out refusing to use it. What could be causing MATLAB to fail in setting up the Fortran compiler?

채택된 답변

jg614
jg614 2019년 2월 18일
Well, I found the solution embarrasingly quickly after continuing to search.
See this answer. The blog post linked in that answer gives instructions for applying the fix on a Mac; ignore all instructions about the Mac SDK.
Quick solution:
  • Edit /usr/local/MATLAB/R2016b/bin/glnxa64/mexopts/gfortran.xml
  • In the line beginning with "LINKLIBS=..." remove both references to gfortranbegin
  • Add -lgcc_s.1 to the end of that line inside the quotes
  • At the bottom of the file, within the GFORTRANBEGIN_LIBDIR block, replace 'dirExists name="$$"' with 'dirExists name="/"'.
  • Save the file and set up the Fortran compiler as normal. This worked for me on Gentoo using gfortran 8.2.0-r6.
  댓글 수: 1
af11111
af11111 2020년 11월 10일
This worked for me on Ubuntu 20.04 for Matlab 2016b!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by