- 
      
- 
        Save zuyu/7d5682a5c75282c596449758d21db5ed to your computer and use it in GitHub Desktop. 
| sudo apt update && \ | |
| sudo apt install build-essential software-properties-common -y && \ | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ | |
| sudo apt update && \ | |
| sudo apt 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 | 
Won't works with new dists
Thanks, worked on Ubuntu 16.04
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.
Won't works with new dists
Same for me, on Ubuntu 20.04: installation of
g++-6throws the errorE: Package 'g++-6' has no installation candidate.
same for me,I can not install gcc-6 on ubuntu 20.04
Won't works with new dists
Same for me, on Ubuntu 20.04: installation of
g++-6throws the errorE: Package 'g++-6' has no installation candidate.same for me,I can not install gcc-6 on ubuntu 20.04
do you have solution ?
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate
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.
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate
- sudo vim /etc/apt/sources.list
- add deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universeto file
- sudo apt update
 4.sudo apt-get install gcc-6 g++-6 -y
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate
- sudo vim /etc/apt/sources.list
- add
deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universeto file- sudo apt update
4.sudo apt-get install gcc-6 g++-6 -y
Thank you for solving out my problem~
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate1. sudo vim /etc/apt/sources.list 2. add `deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to file 3. sudo apt update 4.sudo apt-get install gcc-6 g++-6 -y
This works perfectly
ubuntu 16.04 report error:
update-alternatives: error: alternative g++ can't be slave of gcc: it is a master alternative
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate1. sudo vim /etc/apt/sources.list 2. add `deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to file 3. sudo apt update 4.sudo apt-get install gcc-6 g++-6 -y
This really worked.
Thx for solving my problem!
I am on I am on Ubuntu 22.04.2 , adding deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to the file is not working for me. Does any one know how to solve it ?
Same @maitpate
getting
E: Package 'gcc-6' has no installation candidate E: Package 'g++-6' has no installation candidate
Hi,
This has been useful for me, so I'll chip in.
With ubuntu 20.04 you can't just add the ubuntu-toolchain repository.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test won't work.
You'll get the error: Package gcc-6 is not available.
When you add  deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe to sources.list you get a GPG error because a public encription key doesn't seem to be reachable.
To solve this issue, this is what worked on my fresh ubuntu 22.04 installation:
1. sudo vim  /etc/apt/sources.list
2. add `deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to file
3. sudo apt update
4. Find the key ID after the text: ```NO_PUBKEY``` XXXXXXXXXX
5. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXXXXX
6. sudo apt update
7. sudo install gcc-6 g++-6 -y
Hope it helps (@pratt3000, @maitpate)
Hi, This has been useful for me, so I'll chip in. With ubuntu 20.04 you can't just add the ubuntu-toolchain repository.
sudo add-apt-repository ppa:ubuntu-toolchain-r/testwon't work. You'll get the error:Package gcc-6 is not available.When you adddeb http://dk.archive.ubuntu.com/ubuntu/ bionic main universetosources.listyou get a GPG error because a public encription key doesn't seem to be reachable.To solve this issue, this is what worked on my fresh ubuntu 22.04 installation:
1. sudo vim /etc/apt/sources.list 2. add `deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to file 3. sudo apt update 4. Find the key ID after the text: ```NO_PUBKEY``` XXXXXXXXXX 5. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXXXXX 6. sudo apt update 7. sudo apt install gcc-6 g++-6 -yHope it helps (@pratt3000, @maitpate)
Thanks it works 👍
I moved/renamed them (for my makefile):
8.(optional) sudo mv /usr/bin/g++-6 /usr/bin/g++
9.(optional) sudo mv /usr/bin/gcc-6 /usr/bin/gcc 
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate1. sudo vim /etc/apt/sources.list 2. add `deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to file 3. sudo apt update 4.sudo apt-get install gcc-6 g++-6 -yThis really worked. Thx for solving my problem!
Worked like a charm (on Kub20) thanks !
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate1. sudo vim /etc/apt/sources.list 2. add `deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to file 3. sudo apt update 4.sudo apt-get install gcc-6 g++-6 -y
this is showing me
sudo: vim: command not found
This is showing me
sudo: vim: command not found
vim is just a text editor. You can whether install it using sudo apt install vim or use another one, as nano.
Hi, This has been useful for me, so I'll chip in. With ubuntu 20.04 you can't just add the ubuntu-toolchain repository.
sudo add-apt-repository ppa:ubuntu-toolchain-r/testwon't work. You'll get the error:Package gcc-6 is not available.When you adddeb http://dk.archive.ubuntu.com/ubuntu/ bionic main universetosources.listyou get a GPG error because a public encription key doesn't seem to be reachable.To solve this issue, this is what worked on my fresh ubuntu 22.04 installation:
1. sudo vim /etc/apt/sources.list 2. add `deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to file 3. sudo apt update 4. Find the key ID after the text: ```NO_PUBKEY``` XXXXXXXXXX 5. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXXXXX 6. sudo apt update 7. sudo install gcc-6 g++-6 -yHope it helps (@pratt3000, @maitpate)
Thanks for the solution. When I tried, dk.archive.ubuntu was unreachable, so I used en.archive.ubuntu instead.
Hi, This has been useful for me, so I'll chip in. With ubuntu 20.04 you can't just add the ubuntu-toolchain repository.
sudo add-apt-repository ppa:ubuntu-toolchain-r/testwon't work. You'll get the error:Package gcc-6 is not available.When you adddeb http://dk.archive.ubuntu.com/ubuntu/ bionic main universetosources.listyou get a GPG error because a public encription key doesn't seem to be reachable.To solve this issue, this is what worked on my fresh ubuntu 22.04 installation:
1. sudo vim /etc/apt/sources.list 2. add `deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe` to file 3. sudo apt update 4. Find the key ID after the text: ```NO_PUBKEY``` XXXXXXXXXX 5. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXXXXX 6. sudo apt update 7. sudo install gcc-6 g++-6 -yHope it helps (@pratt3000, @maitpate)
Thank you! It's helpful😺
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate
- sudo vim /etc/apt/sources.list
- add
deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universeto file- sudo apt update
4.sudo apt-get install gcc-6 g++-6 -y
It worked!. Thank you so much.
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate
- sudo vim /etc/apt/sources.list
- add
deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universeto file- sudo apt update
4.sudo apt-get install gcc-6 g++-6 -y
for those who encounter the error:
E: The repository 'http://dk.archive.ubuntu.com/ubuntu bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
consider adding [trusted=yes]:
deb [trusted=yes] http://dk.archive.ubuntu.com/ubuntu/ bionic main universe
After that, I can install them successfully~
I'm on 20.04 and get
E: Package 'gcc-6' has no installation candidate
E: Package 'g++-6' has no installation candidate
- sudo vim /etc/apt/sources.list
- add
deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universeto file- sudo apt update
4.sudo apt-get install gcc-6 g++-6 -yfor those who encounter the error:
E: The repository 'http://dk.archive.ubuntu.com/ubuntu bionic InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default.consider adding
[trusted=yes]:deb [trusted=yes] http://dk.archive.ubuntu.com/ubuntu/ bionic main universeAfter that, I can install them successfully~
I could'nt add the key for some reason but adding bionic as a trusted source as you suggested worked. thanks!
Thanks