Gcc

From Bitpost wiki

g++ on Ubuntu 18.04

This command will install a bunch of new packages including gcc, g++ and make. The second package ensures you get man pages for dev tools.

sudo apt install build-essential  manpages-dev

If you want additional versions of gcc installed, that you can manually switch between, like in gentoo, do this:

sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt install gcc-7 g++-7 gcc-8 g++-8 gcc-9 g++-9 # or just the versions you need

The commands below will configure alternative for each version and associate a priority with it. The default version is the one with the highest priority, in our case that is gcc-9.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7

To manually pick at any time:

sudo update-alternatives --config gcc
# and pick the number you want