9

I'd like to experiment with the new GCC 5.1 C++ compiler on Ubuntu.

How can I install GCC 5.1 on Ubuntu?

I'd prefer some form of pre-built executable that I could just download and install, instead of downloading GCC's sources and building the whole GCC 5.1 from them.

Moreover, since I read libstdc++'s ABI changed in GCC 5, must a new version of libstdc++ be installed with GCC 5.1, too?

MikePro
  • 192
  • 1
  • 2
  • 6
  • This might be a better question for http://askubuntu.com/. – Keith Thompson May 04 '15 at 18:15
  • I've done the install from source on Ubuntu without problems (using a previous GCC 4.9.2 release as the bootstrap compiler). I'm not sure where to go to find it prebuilt. – Jonathan Leffler May 04 '15 at 18:24
  • @KeithThompson: I tried [here](http://askubuntu.com/q/623350/405901). – MikePro May 13 '15 at 20:39
  • I'm voting to close this question as off-topic because it has now also been asked on askubuntu.com: http://askubuntu.com/questions/623350/how-to-install-g-5-1-on-ubuntu-desktop-15-04-64-bit – Keith Thompson May 13 '15 at 20:55

1 Answers1

4

Package g++-5 (gcc version 5.2.1) is available in debian testing or in ubuntu wily. Previous milestones are 4.9 and 4.8. It would be more difficult to get a version in between, like 5.1.

If still satisfied with 5.2.1 then add this line to /etc/apt/sources.list:

deb http://ftp.debian.org/debian/ stretch main

Try to install package and its dependencies:

# apt-get update
# apt-get install g++-5

Then hope it is going to be installed without problems. (It strongly depends which ubuntu version is used on host.) A g++-4.9 install from stable debian (jessie) to ubuntu trusty (gcc 4.8) has been successful for me. When done comment out previously added line from sources list and

# apt-get update

If you are fond of eternal upgrades then set an apt pinning rule instead.

renonsz
  • 571
  • 1
  • 4
  • 17
  • Are you sure it is in stretch? Looks like it is only in unstable now: https://packages.debian.org/search?suite=default&section=all&arch=any&searchon=names&keywords=g%2B%2B-5. – Vadim Kotov Jul 12 '17 at 11:09
  • In jessie (oldstable) g++ is 4.9.2 (https://packages.debian.org/jessie/g++). But rather use stretch or buster with g++-7. The later the merrier. =) – renonsz Sep 12 '17 at 13:44