Here we're assuming you want to have gcc versions 13 & 14 and
clang versions 16 & 17 installed side by-side. Adjust to the
versions you're installing.
You may also wish to adjust the priority (the last number in the
update-alternatives commands below). A higher number means a higher
priority.
We also assume you have previous broken installs of those. If this
is not the case, replace reinstall with install in the below
commands.
-
Install compilers:
sudo apt reinstall gcc-13 g++-13 gcc-14 g++14 clang-16 clang-17 -
Install libs & headers:
sudo apt reinstall libstdc++-13-dev libstdc++-14-dev libclang-16-dev libclang-17-dev -
Set up symlinks manually:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 10 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 10 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 20 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 20 sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 10 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-17 20 -
Set the default C & C++ Compilers:
sudo update-alternatives --set cc /usr/bin/gcc sudo update-alternatives --set c++ /usr/bin/g++
After this you should also be able to configure your defaults by running one of those:
sudo update-alternatives --config <tool>
Where <tool> is one of gcc, g++, clang, clang++, cc or c++.