How to upgrade GCC on Ubuntu

As your Ubuntu installation gets older, you might be missing out on newer C++ features in the GCC compilers. You might want to try to upgrade the GCC compilers to a more recent version.

This can be done by using the ubuntu-toolchain-r/test PPA. For example, on my Ubuntu 14.04 system which had GCC 4.8, I installed GCC 4.9 with these steps:

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

The default GCC will still remain your original version. The newer version will have to be invoked explicitly, for example as gcc-4.9. If you wish to switch the default to the newer version, that is explained in this post.

4 thoughts on “How to upgrade GCC on Ubuntu

    1. ArcherImagine: I’ve not seen Ubuntu updating the GCC version in their LTS over the years its supported. That is why I had to upgrade it myself to use some of the new C++11 features.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.