Updating to latest gcc and g++ on Ubuntu 16.04












10















I recently tried to downgrade to gcc 4.7 since a cfd code I was working on didn't compile with the latest gcc version. But after many errors and the code still not compiling I gave up and would like to go back to the latest gcc and g++ compilers however it seems I may have messed something up.



When I do:



sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo apt-get install gcc-6.2 g++-6.2


or even gcc-5.1 g++-5.1 for that matter, it gives me the following error



Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gcc-6.2
E: Couldn't find any package by glob 'gcc-6.2'
E: Couldn't find any package by regex 'gcc-6.2'
E: Unable to locate package g++-6.2
E: Couldn't find any package by glob 'g++-6.2'
E: Couldn't find any package by regex 'g++-6.2'


and I also tried doing this before



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6.2 g++-6.2


but it doesn't seem to work.
Finally when I just do



sudo apt-get install gcc


it says



Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:5.3.1-1ubuntu1).


I know I still need to install and configure alternatives but doing that doesn't work either as follows



sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5.3 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5.3 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++


Sorry this ended up quite long and please let me know if you need more info. Thanks!



EDIT: I actually got it to work by changing gcc-5.3 to gcc-5 in the above code as that seemed to be what it's called in usr/bin. I will keep it for future reference if anyone faces the same problem.










share|improve this question




















  • 2





    AFAIK gcc and g++ don't install as update-alternatives by default - instead, the gcc and g++ dependency packages install direct links to the default dependencies, like /usr/bin/g++ -> g++-5. Have you tried simply reinstalling the gcc and g++ packages?

    – steeldriver
    Aug 22 '16 at 11:49













  • One way of avoiding this type of issues is to create a VM and install the old compiler version in there.

    – NZD
    Aug 23 '16 at 7:29











  • This hotfix can be fixed in the installation Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version (4:7.3.0-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.

    – JOC KERS
    7 hours ago
















10















I recently tried to downgrade to gcc 4.7 since a cfd code I was working on didn't compile with the latest gcc version. But after many errors and the code still not compiling I gave up and would like to go back to the latest gcc and g++ compilers however it seems I may have messed something up.



When I do:



sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo apt-get install gcc-6.2 g++-6.2


or even gcc-5.1 g++-5.1 for that matter, it gives me the following error



Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gcc-6.2
E: Couldn't find any package by glob 'gcc-6.2'
E: Couldn't find any package by regex 'gcc-6.2'
E: Unable to locate package g++-6.2
E: Couldn't find any package by glob 'g++-6.2'
E: Couldn't find any package by regex 'g++-6.2'


and I also tried doing this before



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6.2 g++-6.2


but it doesn't seem to work.
Finally when I just do



sudo apt-get install gcc


it says



Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:5.3.1-1ubuntu1).


I know I still need to install and configure alternatives but doing that doesn't work either as follows



sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5.3 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5.3 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++


Sorry this ended up quite long and please let me know if you need more info. Thanks!



EDIT: I actually got it to work by changing gcc-5.3 to gcc-5 in the above code as that seemed to be what it's called in usr/bin. I will keep it for future reference if anyone faces the same problem.










share|improve this question




















  • 2





    AFAIK gcc and g++ don't install as update-alternatives by default - instead, the gcc and g++ dependency packages install direct links to the default dependencies, like /usr/bin/g++ -> g++-5. Have you tried simply reinstalling the gcc and g++ packages?

    – steeldriver
    Aug 22 '16 at 11:49













  • One way of avoiding this type of issues is to create a VM and install the old compiler version in there.

    – NZD
    Aug 23 '16 at 7:29











  • This hotfix can be fixed in the installation Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version (4:7.3.0-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.

    – JOC KERS
    7 hours ago














10












10








10








I recently tried to downgrade to gcc 4.7 since a cfd code I was working on didn't compile with the latest gcc version. But after many errors and the code still not compiling I gave up and would like to go back to the latest gcc and g++ compilers however it seems I may have messed something up.



When I do:



sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo apt-get install gcc-6.2 g++-6.2


or even gcc-5.1 g++-5.1 for that matter, it gives me the following error



Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gcc-6.2
E: Couldn't find any package by glob 'gcc-6.2'
E: Couldn't find any package by regex 'gcc-6.2'
E: Unable to locate package g++-6.2
E: Couldn't find any package by glob 'g++-6.2'
E: Couldn't find any package by regex 'g++-6.2'


and I also tried doing this before



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6.2 g++-6.2


but it doesn't seem to work.
Finally when I just do



sudo apt-get install gcc


it says



Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:5.3.1-1ubuntu1).


I know I still need to install and configure alternatives but doing that doesn't work either as follows



sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5.3 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5.3 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++


Sorry this ended up quite long and please let me know if you need more info. Thanks!



EDIT: I actually got it to work by changing gcc-5.3 to gcc-5 in the above code as that seemed to be what it's called in usr/bin. I will keep it for future reference if anyone faces the same problem.










share|improve this question
















I recently tried to downgrade to gcc 4.7 since a cfd code I was working on didn't compile with the latest gcc version. But after many errors and the code still not compiling I gave up and would like to go back to the latest gcc and g++ compilers however it seems I may have messed something up.



When I do:



sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo apt-get install gcc-6.2 g++-6.2


or even gcc-5.1 g++-5.1 for that matter, it gives me the following error



Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gcc-6.2
E: Couldn't find any package by glob 'gcc-6.2'
E: Couldn't find any package by regex 'gcc-6.2'
E: Unable to locate package g++-6.2
E: Couldn't find any package by glob 'g++-6.2'
E: Couldn't find any package by regex 'g++-6.2'


and I also tried doing this before



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6.2 g++-6.2


but it doesn't seem to work.
Finally when I just do



sudo apt-get install gcc


it says



Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:5.3.1-1ubuntu1).


I know I still need to install and configure alternatives but doing that doesn't work either as follows



sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5.3 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5.3 10
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++


Sorry this ended up quite long and please let me know if you need more info. Thanks!



EDIT: I actually got it to work by changing gcc-5.3 to gcc-5 in the above code as that seemed to be what it's called in usr/bin. I will keep it for future reference if anyone faces the same problem.







apt gcc g++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 22 '16 at 12:23







thephysicsguy

















asked Aug 22 '16 at 11:43









thephysicsguythephysicsguy

51114




51114








  • 2





    AFAIK gcc and g++ don't install as update-alternatives by default - instead, the gcc and g++ dependency packages install direct links to the default dependencies, like /usr/bin/g++ -> g++-5. Have you tried simply reinstalling the gcc and g++ packages?

    – steeldriver
    Aug 22 '16 at 11:49













  • One way of avoiding this type of issues is to create a VM and install the old compiler version in there.

    – NZD
    Aug 23 '16 at 7:29











  • This hotfix can be fixed in the installation Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version (4:7.3.0-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.

    – JOC KERS
    7 hours ago














  • 2





    AFAIK gcc and g++ don't install as update-alternatives by default - instead, the gcc and g++ dependency packages install direct links to the default dependencies, like /usr/bin/g++ -> g++-5. Have you tried simply reinstalling the gcc and g++ packages?

    – steeldriver
    Aug 22 '16 at 11:49













  • One way of avoiding this type of issues is to create a VM and install the old compiler version in there.

    – NZD
    Aug 23 '16 at 7:29











  • This hotfix can be fixed in the installation Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version (4:7.3.0-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.

    – JOC KERS
    7 hours ago








2




2





AFAIK gcc and g++ don't install as update-alternatives by default - instead, the gcc and g++ dependency packages install direct links to the default dependencies, like /usr/bin/g++ -> g++-5. Have you tried simply reinstalling the gcc and g++ packages?

– steeldriver
Aug 22 '16 at 11:49







AFAIK gcc and g++ don't install as update-alternatives by default - instead, the gcc and g++ dependency packages install direct links to the default dependencies, like /usr/bin/g++ -> g++-5. Have you tried simply reinstalling the gcc and g++ packages?

– steeldriver
Aug 22 '16 at 11:49















One way of avoiding this type of issues is to create a VM and install the old compiler version in there.

– NZD
Aug 23 '16 at 7:29





One way of avoiding this type of issues is to create a VM and install the old compiler version in there.

– NZD
Aug 23 '16 at 7:29













This hotfix can be fixed in the installation Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version (4:7.3.0-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.

– JOC KERS
7 hours ago





This hotfix can be fixed in the installation Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version (4:7.3.0-3ubuntu2.1). 0 upgraded, 0 newly installed, 0 to remove and 36 not upgraded.

– JOC KERS
7 hours ago










1 Answer
1






active

oldest

votes


















4














Run the following commands in sequence. I was getting same error. This worked for me.



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-snapshot
sudo apt-get install gcc-6 g++-6





share|improve this answer





















  • 8





    Why does sudo apt-get update have be run three times instead of just the first time? In particular, why after the last package installation?

    – Eliah Kagan
    Jan 28 '17 at 3:07










protected by Community 4 hours ago



Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



Would you like to answer one of these unanswered questions instead?














1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Run the following commands in sequence. I was getting same error. This worked for me.



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-snapshot
sudo apt-get install gcc-6 g++-6





share|improve this answer





















  • 8





    Why does sudo apt-get update have be run three times instead of just the first time? In particular, why after the last package installation?

    – Eliah Kagan
    Jan 28 '17 at 3:07
















4














Run the following commands in sequence. I was getting same error. This worked for me.



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-snapshot
sudo apt-get install gcc-6 g++-6





share|improve this answer





















  • 8





    Why does sudo apt-get update have be run three times instead of just the first time? In particular, why after the last package installation?

    – Eliah Kagan
    Jan 28 '17 at 3:07














4












4








4







Run the following commands in sequence. I was getting same error. This worked for me.



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-snapshot
sudo apt-get install gcc-6 g++-6





share|improve this answer















Run the following commands in sequence. I was getting same error. This worked for me.



sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-snapshot
sudo apt-get install gcc-6 g++-6






share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 21 '18 at 1:56









CentaurusA

2,2351424




2,2351424










answered Jan 28 '17 at 2:22









MilindMilind

412




412








  • 8





    Why does sudo apt-get update have be run three times instead of just the first time? In particular, why after the last package installation?

    – Eliah Kagan
    Jan 28 '17 at 3:07














  • 8





    Why does sudo apt-get update have be run three times instead of just the first time? In particular, why after the last package installation?

    – Eliah Kagan
    Jan 28 '17 at 3:07








8




8





Why does sudo apt-get update have be run three times instead of just the first time? In particular, why after the last package installation?

– Eliah Kagan
Jan 28 '17 at 3:07





Why does sudo apt-get update have be run three times instead of just the first time? In particular, why after the last package installation?

– Eliah Kagan
Jan 28 '17 at 3:07





protected by Community 4 hours ago



Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



Would you like to answer one of these unanswered questions instead?



Popular posts from this blog

GameSpot

日野市

Tu-95轟炸機