1

I've been trying to get gfortran working on MacOs Ventura(with a M1 chip) for quite some time. Briefly, the big problem is that gfortran works (when installed via homebrew) until the moment I install Anaconda/conda. After installing Conda, gfortran stops working and I don't know how to make it work correctly. And I need both (conda and gfortran) installed and working. If I install gcc via homebrew, gfortran works perfectly(version 12.2.0). However, when installing Conda the following message appears when I try to compile something in fortran(in this case it was just a "Hello World"):

gfortran hello.f90 -o trash
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/lib/libSystem.tbd' for architecture arm64
collect2: error: ld returned 1 exit status

To get around this, I uninstalled gcc from homebrew and installed it using Conda. I installed the latest available version(11.2.0) using conda install gfortran=11.2.0.

gfortran —version
gfortran: warning: could not understand version 13.02.00
GNU Fortran (GCC) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

And when I run "which gfortran”, it returns: /Users/Odilon/opt/anaconda3/bin/gfortran

However, when trying to compile something the following message is displayed(I am using gfortran hello.f90 -o trash, where "trash" is just the name of the executable I chose):

gfortran: warning: could not understand version 13.02.00
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: error: ld returned 1 exit status

xcode is in the last version(14.2) and Command Line tools is installed. I need gfortran and conda to be installed and working normally on the MacOS. How do I resolve these errors? How can I make gfortran work normally even with Conda installed on the system?

Thanks in advance for the answers and help!

Odilon27
  • 11
  • 1
  • Maybe try the Conda Forge `compilers` package instead (don't install in Anaconda **base**, though). `conda create -n foo -c conda-forge compilers` Unlike the bare `gcc` or `gfortran` packages, it also includes activation scripts that configure env vars when the environment is activated. – merv Jan 27 '23 at 21:15
  • 1
    Alright, after a run that code line, install some packages and run 'conda activate foo', it's works perfectly! Inside this environment the gfortran works directly! Thanks Merv! – Odilon27 Jan 27 '23 at 22:44

0 Answers0