6

How can I downgrade GCC to version 6 on 20.04?

I need GCC6 to compile CUDA9 files.

Trying

apt install gcc-6 is giving me this error:

Package gcc-6 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gcc-6' has no installation candidate
7
  • I'm looking for GCC 6 not g++6, do you happen to know the universe repo url for this package? Thanks
    – nnpractice
    May 7, 2020 at 12:00
  • @KnudLarsen Universe and Multiverse repos are already there. How would I install GCC6 in 20.04?
    – nnpractice
    May 7, 2020 at 12:31
  • I added this line: deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) bionic main universe to /etc/apt/sources.list. And typed apt install g++-6 and got the error: Package 'g++-6' has no installation candidate.
    – nnpractice
    May 7, 2020 at 14:44
  • I also modified the line and removed this part $(lsb_release -sc) so that after the word ubuntu there is a space and bionic. Saved it and tried to install but got the same error.
    – nnpractice
    May 7, 2020 at 14:54
  • Ubuntu 20.04 : I added deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe and did sudo apt update && sudo apt install g++-6 : All OK. gcc-6, g++-6 was installed. May 7, 2020 at 16:26

1 Answer 1

5

Ubuntu 20.04, gcc-6

Please do not remove / change the system gcc : You can have as many gcc versions as you want, installed at the same time. Add (temporarily) a line to /etc/apt/sources.list :

apt [url] bionic main universe, and do

sudo apt update
sudo apt install g++-6

My test : {gcc-6, g++-6} was installed OK.

Using extra compilers, examples : export CC=gcc-6 CXX=g++-6 && ./configure and make CC=gcc-6 CXX=g++-6

Other (non PIE) extra compilers for Ubuntu https://drive.google.com/drive/folders/1xVEATaYAwqvseBzYxKDzJoZ4-Hc_XOJm?usp=sharing

6
  • in your answer you didn't mention the link you wrote to add to the sources file.
    – nnpractice
    May 7, 2020 at 17:49
  • I meant this URL: deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe
    – nnpractice
    May 7, 2020 at 18:45
  • The local mirror is my example. You can use any other valid mirror / URL. May 7, 2020 at 22:30
  • But you should mentioned because when I used deb http://archive.ubuntu.com/ubuntu I got errors. I was able later when you mentioned that because gcc-6 and g++-6 was available on your local server. Those are not available on global mirrors for bionic.
    – nnpractice
    May 8, 2020 at 8:43
  • gcc-6, g++-6 etc. seems to be present at archive.ubuntu.com/ubuntu → universe/g/gcc-6 → archive.ubuntu.com/ubuntu/pool/universe/g/gcc-6 .... so quite puzzling why you cannot fetch it. May 8, 2020 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.