Install latest GFortran on Linux
Newer version of compilers generally have more useful and detailed warning messages. As with any compiler, newer versions of Gfortran may require rebuilding other libraries linked with the Fortran compiler if the ABI presented by libgfortran changes. On Linux, one can switch Gfortran versions with update-alternatives. On Ubuntu, first install the distro-packaged compiler:
apt update
apt install gfortranIf you need a newer GCC / GFortran than your Ubuntu release provides, try:
add-apt-repository universeThe Ubuntu toolchain test PPA is often the simplest way to get a newer GCC / GFortran on Ubuntu: Ubuntu Toolchain Test PPA
Add the PPA by:
add-apt-repository ppa:ubuntu-toolchain-r/test
apt updateInstall the desired compiler version, for example:
apt install gfortran-15Then select the compiler version you want to use. Switch between compiler versions with update-alternatives.
Related:
- Windows: Install latest Gfortran
- macOS: get latest gfortran by
brew install gcc