MEX cannot find Fortran Compiler on macOS Monterey with MATLAB R2022a

9 views (last 30 days)
My mac is running MacOS 12.2.1, and I have Xcode 13.1, gfortran 10.2 installed. However, when I tried
>> mex('-v', '-setup', 'Fortran')
I got the following messages:
********
>> Verbose mode is on.
... Looking for compiler 'Intel Fortran Composer XE' ...
... Looking for environment variable 'ONEAPI_ROOT' ...No.
... Looking for environment variable 'ONEAPI_ROOT' ...No.
... Looking for environment variable 'IFORT_COMPILER21' ...No.
... Looking for environment variable 'IFORT_COMPILER20' ...No.
... Looking for environment variable 'IFORT_COMPILER19' ...No.
... Looking for environment variable 'IFORT_COMPILER18' ...No.
... Executing command 'which ifort' ...No.
Did not find installed compiler 'Intel Fortran Composer XE'.
********
It seems MATLAB was looking for ifort rather than gfortran.
To Install Intel® Fortran Compiler Classic for Mac OS*, I downloaded the installer from https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html#fortran
Then I tried to install ifort, however, it didn't work out. After the installation, typing ifort in my terminal command line still showed
$ command not found: ifort
and mex still didn't work.
I'm getting very negative about all these things now, would anybody help me with this?

Answers (1)

Maneet Kaur Bagga
Maneet Kaur Bagga on 15 Sep 2023
Hi Joe,
The error encountered is because MATLAB R2022a does not supports Gfortran for Mac OS. The last release with Gfortran support for Mac OS was R2015a.
To choose an alternate compiler please refer to the following workaround:
  • Open MATLAB and execute the following command. MATLAB will prompt to select a compiler, choose an alternate compiler that is installed in the system.
mex('-setup', 'Fortran')
Please refer to the following documentation to refer to the Supported and Compatible Compilers:
For a similar error please refer to the following MATLAB Answer:
Hope this helps!
Thank You
Maneet Bagga

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!