MoReFEM
|
Apple made the dubious choice when they switched from GNU compilers to AppleClang ones to provide symbolic links that point toward the new compiler. So on a standard installation of macOS if you type in a terminal gcc
or g++
the odds are you're in fact using AppleClang... Typing gcc -v
will tell you which version you are using!
For most users Apple Clang is fine; getting g++ or LLVM-clang++ is useful for the integration manager to be able to check locally that those compilers are properly supported (and even then CI provides most of those needs - it is only when something is awry than it is practical to be able to check locally).
to install Homebrew and then:
to install gfortran.
For a long time gfortran was installed from this website but in the recent years the archives there weren't without issues; using Homebrew is safer.
Homebrew is your friend here if you want a version of gcc or LLVM-clang on your Mac:
You may have to change write permissions to install it properly (follow the Homebrew instructions in your Terminal to do so).
Please notice that gcc
or g++
will keep pointing to the default ones set up by Apple (see the warning above); you need either to update your path or to explicitly specify the compiler to use, e.g. /usr/local/Cellar/gcc/11.3.0/bin/g++-11
for me at the time of this writing.
Same for clang:
which installs a version to look at in /usr/local/Cellar
(e.g. /usr/local/Cellar/llvm/13.0.1_1/bin/clang++
).
It is better to use along with a compiler the companion standard library, which is:
libstdc++
for g++
libc++
for clang++
On Ubuntu it is rather painful to install properly and use libc++
(or at least it was last time I tried...), so the choice was made to only provide guidance for g++
compiler (continuous integration for instance in Gitlab-CI does not cover the Ubuntu/clang configuration for that reason).
Ubuntu distribution is rather conservative in its compiler version and your Ubuntu is probably shipped with a not very recent gcc.
To install a more recent one (gcc 11 at the time of this writing), type [^1]:
and check with
the correct version is returned.
Running again
allows you to switch back to another version of gcc if need be.
Contrary to Ubuntu, Fedora is shipped with fairly recent versions of compilers; check it but on recent Fedora gcc is already a recent one.
So the install gcc
(and gfortran
)[^1]:
For clang
(and gfortran
)[^1]:
[^1]: You may have a look at the companion project Dockerfiles to get the hint of how the compilers were installed for the Docker images used in continuous integration (keep in mind though there are lot of explicit dependencies as a Docker image is bare-bone - if you're using a desktop Linux OS some of the stuff will already be installed).