The new MacOS Ventura seems to have broken gfortran MacOS version control. To reproduce my error you only have to do
gfortran --version
And the output is
gfortran: warning: could not understand version ‘13.00.00’
GNU Fortran (GCC) 11.3.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.
This in itself is just a warning so it might not be a big deal but it breaks "./configure" scripts that require some MacOS versions, e.g. if you try to compile LoopTools you get the following error (in the log file)
arm64-apple-darwin20.0.0-gfortran: warning: could not understand version '13.00.00'
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: error: ld returned 1 exit status
Since the version cannot be properly read it cannot be compared.
Is there some sort of work around this bug?
I had installed gfortran through conda but aparantly the version is from last year.
I solved it by removing it from conda (had to remove conda entirely due to linking issues) and installed it with brew : brew install gcc.
Related
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!
I am trying to compile a "hello world" text file, but keep receiving an error in my mac terminal:
(base) name#Names-MacBook-Pro-3 File % gfortran -o test.exe try.f90
c.lang (LLVM option parsing): Unknown command line argument '-x86-pad-for-
align=false'. Try: 'clang (LLVM option parsing) --help'.
My fortran version:
GNU Fortran (Homebrew GCC 11.3.0_1) 11.3.0
text file (try.f90) that I wrote in VS:
program try
print*,'hello world!'
end program try
I tried with a space and without a space before print. The code I am using is from a youtuber who uses Atom text editor and the video is from 2020.
I am stuck. Please help.
I resolved my issue by updating Xcode. There was an incompatibility between gfortran and clang. To see available updates:
softwareupdate --list see the list of outdated software.
softwareupdate --install <name>
I faced the same issue and it seems the root cause was Xcode vs Command Line Tools were used. Probably some inconsistency (e.g. I might have upgraded the cli but not the gui).
Anyway, before
$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer/
I fixed this with
$ sudo xcode-select -switch /Library/Developer/CommandLineTools
and then gcc-12 or gfortran from homebrew worked as expected.
FWIW
$ clang --version
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gcc-12 --version
gcc-12 (Homebrew GCC 12.2.0) 12.2.0
Copyright (C) 2022 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.
I've tried to replace the included gcc 4.2.1 compiler on my Mac Book Pro with latest version of Mac OSX but can't figure out what Im doing wrong:
Also this screen scrape from my shell doesn't make sense for me:
Johans-MBP:bin johanlindfors$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Johans-MBP:bin johanlindfors$ which gcc
/usr/local/bin/gcc
Johans-MBP:bin johanlindfors$ /usr/local/bin/gcc --version
gcc (Homebrew GCC 8.2.0) 8.2.0
Copyright (C) 2018 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.
Johans-MBP:bin johanlindfors$
It's because it's actually Apple Clang pretending to be GCC.
The system gcc-4.2.1 compiler is a (very old) legacy of the migration from the gcc to clang compilers. It should never be used for your own code. Edit your .profile or .tcshrc to prepend the newer gcc directory to the path. Or save a lot of time and energy and use MacPorts.
Unfortunately, Clang has established 'absolute' compatibility at gcc-4.2.1: see: clang -E -dM - < /dev/null | grep GNU
That's not a bad thing. Once the compiler gains traction it's going to provide it's own extensions, and no longer track those of others. Many extensions remain compatible like Intel's <x86intrin.h>. It's not really in either compiler's interests to provide too much divergence with extensions...
The 'stable' gcc is now 8.2.0 according to MacPorts. The stable MacPorts clang (which irritably conflicts with OS X) is apparently 7.0.0 ... short story - don't go replacing sets of files arbitrarily that you think might work. Then set up paths correctly - IIRC, MacPorts will do this for you.
I provided a more recent summary: here.
On OS X 10.11.6, I installed gcc 6.2.0 using homebrew. It lives over in usr/local/Cellar/gcc/6.2.0/bin. After getting it to link (it didn't do this automagically), I cd there and try the solution from this other thread to create an alias
ln -s gcc-6 gcc
then gcc --version gives me
cc (GCC) 4.9.2 20141029 (prerelease)
Copyright (C) 2014 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.
All this is because trying to install things crashes because of -rdynamic flags, that I hope is fixed in a newer version.
You created the symlink with the proper target name (gcc) but forgot to set the PATH to your newly installed location (or set it after the system path).
What's confusing is that your system already has a version of gcc installed. You have to override the default path so your gcc command comes first.
edit your ~/.profile file and check PATH adjustment. Add a line in the end which contains:
export PATH=/usr/local/Cellar/gcc/6.2.0/bin:$PATH
Then open a new terminal and ensure that which gcc prints
/usr/local/Cellar/gcc/6.2.0/bin/gcc
I'm installing CUDA on F15. I'm well aware of the fact CUDA needs older versions gcc/g++ and I've installed gcc/g++ 4.5.1, and softlinked them as documented here. I no longer get the error mentioned in that post...however, when I tried compiling the SDK, I get the following error:
make[1]: Entering directory `/home/whao/NVIDIA_GPU_Computing_SDK/C/src/bilateralFilter'
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
make[1]: *** [obj/x86_64/release/filter_kernel.cu.o] Error 1
I suspect that somehow, the older version of g++ in question isn't being recognized? For what it's worth, consider the following two outputs:
[whao#gen-whao-cuda C]$ /usr/local/cuda/bin/gcc --version
gcc (GCC) 4.5.1 20101130 (Red Hat 4.5.1-6)
Copyright (C) 2010 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.
[whao#gen-whao-cuda C]$ /usr/local/cuda/bin/g++ --version
g++ (GCC) 4.5.1 20101130 (Red Hat 4.5.1-6)
Copyright (C) 2010 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.
There is a file named host_config.h where gcc version is checked (the path is /usr/local/cuda/include). You can comment out the appropriate if part (if gcc_version>4.5.* ....). gcc 4.5 may be supported in toolkit 4.1 but if this lines remain, there always be an error before even start compiling.