Selecting compiler versions with update-alternatives

less than 1 minute read

Switch compiler versions

Switch between compilers e.g. gcc-6 and gcc-8 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-8:

apt install gcc-8

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

The last number is priority. The highest priority number is used in “automatic” update-alternatives mode.

Leave a Comment