Install GNU Compiler Collection (GCC) On Ubuntu 22.04 LTS

Install GNU Compiler Collection (GCC) On Ubuntu 22.04 LTS

GCC was originally written as the compiler for the GNU operating system. GNU compiler collection is a list of compilers and libraries for C++, Objective-C, Ada, Go, C, Fortran, and D programming languages. These days, various projects are compiled using GCC so it is always better to install GNU compiler collection or GCC on Ubuntu 22.04 LTS to avoid any future conflicts.

Install GNU Compiler Collection (GCC) On Ubuntu 22.04 LTS

Update Ubuntu before GCC Installation on Ubuntu 22.04 or 20.04

Run the following command in your Ubuntu to update Ubuntu before proceeding the installation process.

sudoapt update
sudo apt upgrade

There are multiple ways to install GCC on Ubuntu and it’s derivatives.

Install GCC with the Ubuntu Repository

In this method, you can easily install GCC on Ubuntu using official repository.  You will find the meta-package called “build-essential” in the default Ubuntu repositories. The build-essential includes the GNU compiler collection. So, Run the following command to install GCC on Ubuntu 22.04 LTS

sudo apt install build-essential
or
sudo apt install gcc

If you need a manual page then you can also install it using the following command:

sudo apt-get install manpages-dev

To verify your installation, run the following command whether you have successfully installed GCC on Ubuntu 22.04 LTS or not.

gcc --version

In another method, You can also  install GCC with Ubuntu via Toolchain PPA. Run the following command to add the PPA.

sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa -y

Now, update your Ubuntu.

sudo apt update

It’s time to install GCC on Ubuntu by executing the following command.
To install a specific version of the GCC compile:

GCC Compiler 13

sudo apt install g++-13 gcc-13

GCC Compiler 12

sudo apt install g++-12 gcc-12

Just in case if you need to install multiple GCC compiler versions then run the following command. You can install multiple versions of GCC along with G++ using the following command:

pre> sudo apt install gcc-9 g++-9 gcc-10 g++-10 gcc-11 g++-11 g++-12 gcc-12 g++-13 gcc-13

Leave a Comment