1

I am trying to install Fortran on my MacBook MacOS Monterey (version 12.2.1) M1 chip laptop. I downloaded and installed the gfortran from this website (gfortran 12-Dec 18, 2021): https://github.com/fxcoudert/gfortran-for-macOS/releases with no issues.

I then followed the instructions on this link: https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/ and when following the steps to do a 'quick check' with C++, I receive these errors:

ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0'
ld: warning: directory not found for option '-L/opt/R/arm64/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sourceCpp_3.so] Error 1

I attempted to solve the issue by inputted this command in terminal:

ln -s /usr/local/gfortran /opt/R/arm64

But I received a "Permission denied" output.

There may be issues with installing gfortran on Monterey M1 chip, but I think the main problem is where my gfortran is located on my laptop. I am not sure. Does anyone have a solution as to how to relocate gfortran on my laptop through Terminal?

Much appreciated.

Dominika Boron
  • 11
  • 1
  • 1
  • 5

1 Answers1

0

Have you tried to install and update XCode Command Line Tools? In principle, it comes with gcc and gfortran. Once installed, you do not need to use directly XCode to run gfortran on a terminal. XCode is available from the app store.

You can also install gcc (which contain gfortran) via brew brew install gcc.

Damien
  • 13
  • 5
  • Yes, I installed and updated it. I found the issue, I had to re-install R version 4.1.2.pkg NOT 4.1.2-arm64.pkg (apparently the arm64 package causes some issues with installing packages). And then not update the VGAM package 1.1-5 to 1.1-6. It wouldn't allow me to update the VGAM package and install SpiecEasi at the same time. Once I chose "no" for updates it installed smoothly! – Dominika Boron Feb 14 '22 at 20:10
  • 1
    I have XCode 14.0 installed on an M1 MBP, including the commandline tools (checked with `xcode-select --install`) and I only got `gcc` in the path, not `gfortran`. – hans_meine Sep 25 '22 at 10:30