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.
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.
Install Additional GCC Language Frontends
GCC supports multiple programming languages via separate frontend packages in Arch Linux.
Here are the available frontend packages:
| Package | Language | Install Command |
|---|---|---|
| gcc-fortran | Fortran | sudo pacman -S gcc-fortran |
| gcc-ada | Ada (GNAT) | sudo pacman -S gcc-ada |
| gcc-go | Go | sudo pacman -S gcc-go |
| gcc-d | D | sudo pacman -S gcc-d |
| gcc-objc | Objective-C | sudo pacman -S gcc-objc |
| gcc-rust | Rust | sudo pacman -S gcc-rust |
| gcc-m2 | Modula-2 | sudo pacman -S gcc-m2 |
| gcc-gcobol | COBOL | sudo 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:
- Opening a new terminal session
- 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
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++ compilersbase-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.
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 ❤️!
We do not support or promote any form of piracy, copyright infringement, or illegal use of software, video content, or digital resources.
Any mention of third-party sites, tools, or platforms is purely for informational purposes. It is the responsibility of each reader to comply with the laws in their country, as well as the terms of use of the services mentioned.
We strongly encourage the use of legal, open-source, or official solutions in a responsible manner.


Comments