How can I downgrade GCC to version 6 on 20.04?

10,964

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

Share:
10,964

Related videos on Youtube

nnpractice
Author by

nnpractice

Updated on September 18, 2022

Comments

  • nnpractice
    nnpractice almost 2 years

    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
    
  • nnpractice
    nnpractice about 4 years
    in your answer you didn't mention the link you wrote to add to the sources file.
  • nnpractice
    nnpractice about 4 years
    I meant this URL: deb http://dk.archive.ubuntu.com/ubuntu/ bionic main universe
  • Knud Larsen
    Knud Larsen about 4 years
    The local mirror is my example. You can use any other valid mirror / URL.
  • nnpractice
    nnpractice about 4 years
    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.
  • Knud Larsen
    Knud Larsen about 4 years
    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.
  • nnpractice
    nnpractice about 4 years
    I literally told you I added deb http://archive.ubuntu.com/ubuntu to sources file and updated and tried to install and got the error I showed you in my question.