Arch Linux

How to Install GCC for Arch Linux

GCC (GNU Compiler Collection) comprises compilers for well-known programming languages such as C, C++, Go, Fortran, Objective-C, and many more. The GCC is completely free and provides cross-platform support for Linux, Windows, and multiple BSD-based systems.

Apart from this, one can suggest or make enhancements to GCC and you can utilize the enhancements done by other developers/users as well. Moreover, the GCC can be used to make executable files for other systems which makes it the best choice for embedded systems (as they don’t have any compiler).

Keeping in view the importance of GCC, this guide demonstrates the step-by-step procedure to install GCC on Arch Linux.

So, let’s start:

How to install GCC on Arch Linux

The GCC is available on the official repository of Arch, thus the Arch package manager can be used to install it.

Step 1: First, synchronize and update the package’s database using the following command.

$ sudo pacman -Syu

Step 2 (optional): After synchronizing the database, you can look for the availability of GCC on Arch Linux by using the following command.

$ sudo pacman -Ss gcc

The output shows the dependencies that are available on the official repository of Arch Linux.

Step 3: Install GCC on Arch Linux by issuing the following command in the terminal.

$ sudo pacman -S gcc

Once installed successfully, verify its version by issuing the following command.

$ gcc --version

How to install older versions of GCC on Arch Linux

What if you have created a project using an old version of GCC and you are unable to compile it? For this, you may need older versions.

The older versions can be obtained easily from AUR (Arch User Repository) and to access it, you may need an AUR helper (yay, pacaur)To do so, you can make use of any AUR helper (pacaur, yay,).

For instance, the command written below will install “gcc 4.9” on your Arch Linux system.

$ yay -S gcc49

Note: Click here to get the list of previous releases of GCC

How to remove GCC on Arch Linux

The GCC can be removed from your Arch Linux system by providing the following command.

$ sudo pacman -R gcc

However, you can use the -Rcnu flag to remove GCC and the unnecessary dependencies as well. In our case, the following command would remove GCC and all its dependencies.

$ sudo pacman -Rcnu gcc

The output shows that the gcc and all its dependencies have been removed successfully.

Conclusion

GCC (GNU Compiler Collection) is a resourceful compiler that can be obtained on Arch Linux with the help of a package manager of Arch Linux. GCC provides front ends for various programming languages such as C, C++, Go, Fortran, and many more. This guide demonstrates the way to install the latest release as well as any older version of GCC on Arch Linux.

About the author

Adnan Shabbir