Skip to content

Instantly share code, notes, and snippets.

@ilovejs
Last active March 30, 2022 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilovejs/f2e52d1e90ff6eb077a8c7855fe0d891 to your computer and use it in GitHub Desktop.
Save ilovejs/f2e52d1e90ff6eb077a8c7855fe0d891 to your computer and use it in GitHub Desktop.
As mentioned in the comment section, GCC versions lower than 7 are still available in xenial repository. You can follow the following steps to install gcc-5:

Add xenial to /etc/apt/sources.list
Open sources.list with sudo

sudo vim /etc/apt/sources.list

Add the following lines in the sources.list file

deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe

sudo apt update
sudo apt install g++-5 gcc-5
Reference answer: Install gcc 4.9 at ubuntu 18.04

To change default gcc version to gcc 5 you can follow this link. Below I am adding the steps for completeness.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 5
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 5

And then select the correct version manually as below:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

If you find this answer helpful, please also consider upvoting the reference answer from which most of my answer is borrowed.

https://askubuntu.com/questions/1235819/ubuntu-20-04-gcc-version-lower-than-gcc-7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment