Whether you’re compiling a small C program, building software from source, or installing packages from the AUR, GCC on Arch Linux is an essential tool. The GNU Compiler Collection powers much of the Linux ecosystem, and Arch’s rolling release model ensures you always get the latest stable version.

In this complete guide, you’ll learn how to install GCC on Arch Linux, verify it works, compile test programs, add language frontends like Fortran and Go, troubleshoot common errors, and remove it cleanly if needed.

By the end, you’ll have a fully functional development environment ready for C, C++, and beyond.

What Is GCC on Arch Linux?

GCC (GNU Compiler Collection) provides compilers for:

  • C (gcc)
  • C++ (g++)
  • Fortran
  • Go
  • Ada
  • D
  • Objective-C
  • Rust
  • Modula-2
  • COBOL

Arch Linux includes GCC in its official core repository, meaning installation is simple using pacman.

Because Arch follows a rolling release model, GCC is regularly updated to the latest stable upstream version.

READ 👉  What's New in AnduinOS 1.1.6, 1.2.6, and 1.3.3?

Step 1: Update Arch Linux Before Installing GCC

Before installing new software, always synchronize and update your system to avoid dependency conflicts.

sudo pacman -Syu

This command:

  • Syncs the package database
  • Upgrades installed packages
  • Ensures you get the latest GCC build

If your user isn’t configured for sudo, run commands as root or configure sudo privileges first.

Step 2: Install GCC on Arch Linux

Arch Linux offers two main ways to install GCC:

Option 1: Install the gcc Package (Minimal Setup)

If you only need to compile C or C++ programs:

sudo pacman -S gcc

This installs:

  • gcc (C compiler)
  • g++ (C++ compiler)
  • gcc-libs
  • Required runtime libraries
  • binutils

This is ideal for:

  • Writing small C/C++ programs
  • Learning programming
  • Lightweight development environments

Option 2: Install base-devel (Recommended for Developers)

If you plan to:

  • Build AUR packages
  • Compile software from source
  • Use makepkg
  • Use AUR helpers like Yay or Paru

Install:

sudo pacman -S base-devel

The base-devel metapackage includes:

  • gcc
  • make
  • autoconf
  • automake
  • patch
  • fakeroot
  • pkgconf
  • And 20+ essential build tools

For most Arch Linux developers, base-devel is the recommended choice.

Step 3: Verify GCC Installation

After installation, confirm everything works properly.

Check GCC Version

gcc --version

You should see output similar to:

gcc (GCC) 15.x.x

Check G++ Version

g++ --version

Confirm Binary Location

which gcc

Expected output:

/usr/bin/gcc

If these commands return valid results, GCC is successfully installed.

Step 4: Compile a Test Program in C

Testing ensures:

  • Compiler works
  • Linker works
  • Standard libraries are installed

Create a C Test File

Create hello.c:

#include <stdio.h>

int main() {
    printf("Hello, World from GCC on Arch Linux!\n");
    return 0;
}

Compile the Program

gcc hello.c -o hello

Run It

./hello

Expected output:

Hello, World from GCC on Arch Linux!

Step 5: Compile a C++ Program

Create hello.cpp:

#include <iostream>

int main() {
    std::cout << "Hello, World from G++ on Arch Linux!" << std::endl;
    return 0;
}

Compile:

g++ hello.cpp -o hello_cpp

Run:

./hello_cpp

If it executes correctly, your C++ environment is fully functional.

READ 👉  How to Set Up a WireGuard VPN on Linux (Step-by-Step Guide)

Install Additional GCC Language Frontends

GCC supports multiple programming languages via separate frontend packages in Arch Linux.

Here are the available frontend packages:

PackageLanguageInstall Command
gcc-fortranFortransudo pacman -S gcc-fortran
gcc-adaAda (GNAT)sudo pacman -S gcc-ada
gcc-goGosudo pacman -S gcc-go
gcc-dDsudo pacman -S gcc-d
gcc-objcObjective-Csudo pacman -S gcc-objc
gcc-rustRustsudo pacman -S gcc-rust
gcc-m2Modula-2sudo pacman -S gcc-m2
gcc-gcobolCOBOLsudo pacman -S gcc-gcobol

You can install multiple frontends at once:

sudo pacman -S gcc-fortran gcc-go

All frontends use the same GCC backend and optimization engine.

Troubleshooting GCC on Arch Linux

Even on Arch, you might encounter issues. Here are the most common ones.

Error: “gcc: command not found”

If you see:

bash: gcc: command not found

Try:

  1. Opening a new terminal session
  2. Confirm installation:
pacman -Qs gcc

If not installed, reinstall:

sudo pacman -S gcc

Linker Error: Missing Library

Example:

/usr/bin/ld: cannot find -lssl

Update the file database:

sudo pacman -Fy

Search for the missing file:

pacman -F libssl.so

Install the package listed (for example):

sudo pacman -S openssl

Missing Header File

Example:

fatal error: curl/curl.h: No such file or directory

Search for the header:

pacman -F curl.h

Install the required package:

sudo pacman -S curl

Unlike Debian-based systems, Arch includes development headers in the main package — no separate -dev packages needed.

Useful GCC Compiler Flags

To write optimized and safe code, use these flags:

  • -Wall → Enable common warnings
  • -Wextra → Additional warnings
  • -O2 → Standard optimization
  • -g → Debug symbols (for GDB)
  • -std=c17 → Specify C standard
  • -std=c++20 → Specify C++ standard
READ 👉  Harden Your Linux System with systemd Security Options: A Comprehensive Guide

Example:

gcc -Wall -Wextra -O2 -std=c17 -o program program.c

These flags improve code quality and performance.

Remove GCC from Arch Linux

If you installed GCC standalone:

sudo pacman -Rns gcc

If you installed base-devel and want to remove all development tools:

sudo pacman -Rns base-devel

Verify removal:

gcc --version

If removed, you’ll see:

bash: gcc: command not found

Frequently Asked Questions

What’s the difference between gcc and base-devel?

  • gcc → Only C and C++ compilers
  • base-devel → Full development toolkit for AUR and source builds

Choose base-devel if you build packages frequently.

Should I use gcc or g++ for C++?

Use:

g++ program.cpp -o program

g++ automatically links the C++ standard library.

Is GCC required for AUR packages?

Yes. Most AUR packages require base-devel, which includes GCC.

Final Thoughts

Installing GCC on Arch Linux is straightforward, but choosing the right setup depends on your needs. If you’re just compiling small programs, the standalone gcc package is enough. For serious development or AUR usage, base-devel is the smarter choice.

Once installed, you can:

  • Compile C and C++ programs
  • Add support for Fortran, Go, Ada, and more
  • Use powerful compiler flags
  • Debug efficiently
  • Build software from source with confidence

With GCC properly configured, your Arch Linux system becomes a powerful development workstation ready for everything from small projects to full-scale applications.

Did you enjoy this article? Feel free to share it on social media and subscribe to our newsletter so you never miss a post!

And if you'd like to go a step further in supporting us, you can treat us to a virtual coffee ☕️. Thank you for your support ❤️!
Buy Me a Coffee

Categorized in: