Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to upgrade GCC on Ubuntu

📅 2014-May-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 📚 Archive

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.