- sudo apt-get install -y software-properties-common
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
- sudo apt update
- sudo apt install g++-9
Set it up so the symbolic links gcc, g++ point to the newer version:
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9
- sudo update-alternatives --config gcc
- gcc --version
- g++ --version