The GNU Compiler Collection (GCC) is a collection of compilers and libraries developed by the GNU Project that supports programming languages such as C, C++, Objective-C, Fortran, Go, and many more. GCC is a core part of the Linux operating system and many open-source projects and tools. Linux kernel is also compiled with GCC, so it’s a big deal in the open-source community. If you’re a new user or student looking for a Linux system to start learning on, the easiest place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners and folks looking for easier Linux distribution to use. Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices. For more about GCC, please visit its project page. To get started with installing the GCC compiler on Ubuntu, follow the steps below:
How to install GCC on Ubuntu Linux
Out of the box, Ubuntu repositories contain a build-essential package that contains the GCC compiler, g++, make and a lot of libraries and other utilities required for compiling other packages and tools. So installing the GCC compiler on Ubuntu is as simple as installing the build-essential package. To do that, run the commands below: The commands install many other packages, GCC, g++, and make. If you’re a developer and want to install the manual page for GCC, simply run the commands below: After installing, to verify that GCC is successfully installed and functioning, simply use the GCC –version command as shown below: That should print out the output as shown below: This is how to install the GCC compiler on Ubuntu if you don’t already have it installed.
How to install multiple versions of GCC
Those who want to install multiple versions of the GCC compiler can use option #2. New versions of the GCC compilers support new languages, better performance, and extended features. If you want to take advantage of these additional features, then installing the latest or multiple should be ideal. To install the latest versions of the GCC compilers, you will have to add a third-party PPA repository to Ubuntu and install it from there. To do that, simply run the commands below: After adding the repository above, you can then install multiple GGC versions using their version number. Example: Because you have multiple versions of the GCC compiler installed, there’s a priority number that gets associated with each. The version with the highest priority will be the default system compiler. You will have to run the commands below to set the default system compiler associating each with a priority number. In the case below, gcc-9 is the version with the highest priority [ 90 ]. Later if you want to change the default version use the update-alternatives command below: There should be multiple choices depending on the number of compilers installed. Select your choice and press Enter. That should update the system with the current default. Conclusion You have learned how to install the GCC compiler on Ubuntu 18.04 | 16.04. If you find any error above, please use the comment form below to report it.