Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install gcc 6 on Ubuntu
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
gcc -v
@Manojbhat09

This comment has been minimized.

Copy link

@Manojbhat09 Manojbhat09 commented May 30, 2020

Thanks

@luk0y

This comment has been minimized.

Copy link

@luk0y luk0y commented Sep 3, 2020

Won't works with new dists

@MichaelZaidman

This comment has been minimized.

Copy link

@MichaelZaidman MichaelZaidman commented Oct 13, 2020

Thanks, worked on Ubuntu 16.04

@goepp

This comment has been minimized.

Copy link

@goepp goepp commented Nov 30, 2020

Won't works with new dists

Same for me, on Ubuntu 20.04: installation of g++-6 throws the error E: Package 'g++-6' has no installation candidate.

@opptimus

This comment has been minimized.

Copy link

@opptimus opptimus commented Dec 10, 2020

Won't works with new dists

Same for me, on Ubuntu 20.04: installation of g++-6 throws the error E: Package 'g++-6' has no installation candidate.

same for me,I can not install gcc-6 on ubuntu 20.04

@caesar6747

This comment has been minimized.

Copy link

@caesar6747 caesar6747 commented Jan 25, 2021

Won't works with new dists

Same for me, on Ubuntu 20.04: installation of g++-6 throws the error E: Package 'g++-6' has no installation candidate.

same for me,I can not install gcc-6 on ubuntu 20.04
do you have solution ?

@Gideon-Felt

This comment has been minimized.

Copy link

@Gideon-Felt Gideon-Felt commented Mar 13, 2021

I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate

@goepp

This comment has been minimized.

Copy link

@goepp goepp commented Mar 14, 2021

The error message E: Package 'g++-6' has no installation candidate should come from the fact that after Ubuntu 16.04 LTS, the version of g++ is greater than 6 (g++-7 for 18.04 [source] and g++-9 for 20.04 source). The same remark goes for gcc.
A possible workaround would be to download the package source (link Download source package here) and install it from source.
I don't know what is the best way to install it from source though, especially for taking dependencies into account.

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