Skip to content

Instantly share code, notes, and snippets.

@beci
Created October 15, 2015 07:18
Show Gist options
  • Select an option

  • Save beci/2a2091f282042ed20cda to your computer and use it in GitHub Desktop.

Select an option

Save beci/2a2091f282042ed20cda to your computer and use it in GitHub Desktop.
use gcc 5.x on ubuntu 14.04
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
@paomian

paomian commented Sep 11, 2017

Copy link
Copy Markdown

gcc7

sudo add-apt-repository ppa:jonathonf/gcc-7.1
sudo apt-get update
sudo apt-get install gcc-7 g++-7

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7

@NorimasaNabeta

Copy link
Copy Markdown

thx

@bryceschober

Copy link
Copy Markdown

WARNING @beci @vineeshvs @hallahan @Antttooon @MagnetonBora @rrogers @dtamez @benzkji @NorimasaNabeta:

The ppa:ubuntu-toolchain-r/test has old compiler builds that don't correctly compile some dkms kernel drivers, like nVidia, and you can get your installation pretty broken with the compilers from this PPA. See this launchpad issue for details.

@yuchen-xue

yuchen-xue commented Mar 14, 2018

Copy link
Copy Markdown

update-alternatives: error:

I'm working on Ubuntu 16.04. The first three code ran properly, but when I was running the code

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5

I got the error:

update-alternatives: error: alternative g++ can't be slave of gcc: it is a master alternative

Can someone answer me what may have gone wrong?

@sg552

sg552 commented Apr 11, 2018

Copy link
Copy Markdown

good job, works , thank you!

@rehmanzafar

Copy link
Copy Markdown

Thank you, it worked.

@mathieu-aubin

Copy link
Copy Markdown

fast&clean

kudos

@apoorva-js

Copy link
Copy Markdown

@SeanSyue I'm got the same error as yours. Can you please help me if you figured it out.

@JOELEJAUNE

Copy link
Copy Markdown

thank you

@NokiaDDT

Copy link
Copy Markdown

@dongnhzigexn

Copy link
Copy Markdown

It works like a charm on Ubuntu 18.04. Thank you 👍

@anandbhaskaran

Copy link
Copy Markdown

Thanks

@SahilTamboli23

Copy link
Copy Markdown

worked .....thanks

@Tectract

Copy link
Copy Markdown

ppa:ubuntu-toolchain-r/test

seems like it's not being updated or bugfixed properly and could even leave your Ubuntu 14.04 machine in an unbootable state. Beware...

See here a bunch of people breaking their installations of apt-get and gnome by blindly using that repo:

https://askubuntu.com/questions/777803/apt-relocation-error-version-glibcxx-3-4-21-not-defined-in-file-libstdc-so-6#

@Nukemenonai

Copy link
Copy Markdown

the following error appears when trying to compile using the flag -fsanitize=signed-integer-overflow

/usr/bin/ld: unrecognized option '--push-state--no-as-needed'
/usr/bin/ld: use the --help option for usage information

@aspenstarss

Copy link
Copy Markdown

It's work for me!
Thanks!

@mandardeshmukh03

mandardeshmukh03 commented Dec 21, 2021

Copy link
Copy Markdown

For me this worked:
sudo apt-add-repository "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main"
sudo apt-get update
sudo apt-get install gcc-5 g++-5

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