GCC is an abbreviation for GNU Compiler Collection. Most languages used to build the Linux kernel are C and object-oriented programming languages. In this article, we will discuss how to install GCC in Arch Linux.
Overview
The creators of the Linux kernel had to construct a free and open-source compiler in order to produce the kernel and modules. The GNU project is the one behind the creation of the GCC compiler. It comes pre-installed with the operating system in all current Linux distributions. The GCC compiler can be used to compile object-oriented programming languages, C, C++, Ada, Go, and a few others. You can use the GCC compiler on a Linux machine to compile code on your terminal shell.
Compilers for popular programming languages like Fortran, Objective-C, Ada, and many more are included in the GCC (GNU Compiler Collection). The GCC offers cross-platform compatibility for Linux, Windows, and many BSD-based platforms and is totally free.
In addition, anyone can recommend or add improvements to GCC, and you can use the improvements made by other users or developers. It is also the ideal option for embedded systems (since they lack a compiler) because it may be used to create executable files for other systems.
Given the significance of GCC, this post walks readers through the step-by-step process of installing GCC on Arch Linux.
How to Install GCC in Arch Linux
Check GCC Version
You must determine whether the GCC compiler is already installed on your Linux system before proceeding to install it. Use the command below to check and see if it is, and what the version is, if ever it is already installed.
Syntax:
$ gcc --version

As you can see in the above screenshot, the version for our example is 12.2.0. You don’t need to install GCC if you get the following notice in your shell. You will need to install GCC on your system if you can’t find it there.
The GCC can be installed using the Arch package management because it is part of the official repository for Arch.
First, use the following command to synchronize and update the package’s database.
Syntax:
$ pacman -Syu

In the screenshot above, you can see that upon running the pacman -Syu
command, you will be prompted to type Y to proceed with the installation. Depending on your internet connection, this may take a while to complete.
Once the installation has been completed, it should look something like the screenshot below.

Next, we need to check if GCC is available. You can use the following command to check whether GCC is available on Arch Linux after synchronizing the database.
Syntax:
$ pacman -Ss gcc

The below screenshot is what you get upon running the above command.

This output displays the dependencies that are offered by Arch Linux’s official repository.
Install GCC on Arch Linux
Execute the following command in the terminal to install GCC on Arch Linux.
Syntax:
$ pacman -S gcc

Upon running the command above, you will see which version will be installed on your system and also the total size of the package to be installed. You will then be prompted for confirmation to proceed with the installation.

In this screenshot, you can see that the installation has been completed successfully.
Use the following command to check the version after it has been successfully installed.
Syntax:
$ gcc --version

Here, you can see the version of GCC (12.2.0) that we have just installed. This should be the latest version at the time of this writing.
How to install previous GCC versions on Arch Linux
What if you cannot build a project you produced with an outdated version of GCC? In this scenario, you will need a previous or an older version of GCC.
You may access the earlier versions through AUR (Arch User Repository), although it might require an AUR helper (yeah, pacaur). You can use any AUR helper to do this (pacaur, yay,).
The command listed below, for instance, will install “gcc 4.8” on your Arch Linux system.
Syntax:
$ yay -S gcc48

If this command does not work on your Arch Linux system, it might be because you do not have yay installed yet.
Install Git on Arch Linux
Git is fundamentally a collection of command-line utilities created to run in a Unix-style command-line environment. Unix command line terminals are included in many contemporary operating systems, including Linux and macOS. As a result, while using Git, Linux and macOS complement operating systems.
To install yay, first, you need to install git. If you do not have git already installed, you can use the command below to do install it.
Syntax:
$ pacman -S git

Install yay on Arch Linux
Yay is an AUR-compatible Pacman wrapper. After deciding which packages need to be installed or upgraded, it passes options to Makepkg and Pacman. You can use the commands below to
Syntax:
$ git clone https://aur.archlinux.org/yay.git
$ cd yay
$ makepkg -si
Run the commands above in their order, the git command first, then you change the directory to the yay folder, which was created upon running the git command above.

Next, you need to run the makepkg
command.

This screenshot shows that the command above has been completed successfully.
The next thing you would want is to synchronize package databases for yay. First, you must move out of the yay directory using the cd
command. Run the commands below in order.
Syntax:
$ cd ..
$ yay

Upon running the yay
command you will be prompted to proceed with the installation.

n this screenshot, you can see that package databases have synchronized successfully.
Uninstall GCC on Arch Linux
Use the following command to remove the GCC from your Arch Linux system.
Syntax:
$ sudo pacman -R gcc

However, you can also eliminate GCC and any unneeded dependencies by using the -Rcnu
switch. In our example, the following command would uninstall GCC and all its dependencies.
Syntax:
$ sudo pacman -Rcnu gcc

Upon running the above command, it will check for any dependencies and show the total package size or packages to be removed. You will then be prompted if you want to continue.
The output below confirms that the removal of GCC was successful, and if there were any, all of its dependencies as well should have been removed.

With the aid of an Arch Linux package manager, GCC (GNU Compiler Collection) is a capable compiler that can be installed on Arch Linux. GCC offers front ends for many different programming languages, including C, C++, Go, Fortran, and others. This tutorial shows how to install both the most recent release and any previous version of GCC on Arch Linux.
If this guide helped you, please share it. ?