Selecting compiler versions with update-alternatives

Switch compiler versions

Switch between compilers e.g. gcc-5 and gcc-6 with simple commands like:

update-alternatives --config g++
update-alternatives --config gfortran

update-alternatives works with virtually any program including Java and Python.

Add compilers

Example of adding gcc-7:

apt install gcc-7

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 10

Leave a Comment