Arch keeps its compiler toolchain close to upstream, so installing GCC usually means installing the current GNU C and C++ compiler rather than choosing between fixed distro release branches. To install GCC on Arch Linux, use the official gcc package for gcc and g++, or install base-devel when you also need the build tools expected by AUR packages and source builds.
Update Arch Linux
Synchronize the package database and upgrade all installed packages before installing new software. This prevents dependency conflicts and ensures you get the latest available version of GCC.
sudo pacman -Syu
These commands use
sudofor tasks that need root privileges. If your user is not in the sudoers file yet, run the commands as root or follow the guide on how to add and manage sudo users on Arch Linux.
Install GCC on Arch Linux
Arch Linux offers two practical package choices. The standalone gcc package provides the C and C++ compiler frontends, while the base-devel package depends on GCC plus the standard tools used to build Arch packages.
| Package Choice | What It Installs | Best For |
|---|---|---|
gcc | gcc, g++, runtime libraries, and required compiler dependencies | Minimal C and C++ compiler setup |
base-devel | gcc plus make, autoconf, automake, patch, pkgconf, fakeroot, and other Arch package-build tools | AUR builds, makepkg, and source builds |
Arch does not split the C++ compiler into a separate official g++ package. The related gcc-libs package contains runtime libraries and can be installed as a dependency without giving you the compiler commands.
Install GCC with the gcc Package
Install GCC as a standalone package from the core repository:
sudo pacman -S gcc
This installs the C and C++ compilers (gcc and g++) along with the required runtime libraries.
Install GCC with base-devel
Install the base-devel metapackage, which includes GCC and the full set of build tools:
sudo pacman -S --needed base-devel
The --needed flag avoids reinstalling packages that are already present. Use this method if you build AUR packages with helpers such as Yay or Paru, because makepkg workflows expect the base-devel toolchain.
GCC does not install version-control tools. If your source workflow pulls projects from Git repositories, install Git on Arch Linux separately.
Verify GCC Installation on Arch Linux
Confirm GCC is installed and check which version is active on your system.
Check the GCC version:
gcc --version
The first line shows the active GCC branch. Expect the exact branch and point release to change with Arch rolling updates:
gcc (GCC) 16.x.x
Check the G++ (C++ compiler) version:
g++ --version
The g++ command reports the same GCC branch because it comes from the same package:
g++ (GCC) 16.x.x
Confirm both compiler commands are on your shell path:
command -v gcc
command -v g++
Expected output:
/usr/bin/gcc /usr/bin/g++
Package ownership confirms both commands come from the gcc package:
pacman -Qo /usr/bin/gcc /usr/bin/g++
Relevant output includes:
/usr/bin/gcc is owned by gcc 16.x.x /usr/bin/g++ is owned by gcc 16.x.x
Compile Test Programs with GCC on Arch Linux
Test the compiler by building and running simple C and C++ programs. This confirms that GCC, the linker, and the standard libraries are all working correctly.
Compile a C Program
Create a test file called hello.c:
#include <stdio.h>
int main() {
printf("Hello, World from GCC on Arch Linux!\n");
return 0;
}
Compile and run it:
gcc hello.c -o hello
./hello
Expected output:
Hello, World from GCC on Arch Linux!
Compile a C++ Program
Create a test file called hello.cpp:
#include <iostream>
int main() {
std::cout << "Hello, World from G++ on Arch Linux!" << std::endl;
return 0;
}
Compile and run it with g++:
g++ hello.cpp -o hello_cpp
./hello_cpp
Expected output:
Hello, World from G++ on Arch Linux!
Use Common GCC Compiler Flags
For everyday local builds, start with warnings enabled and add optimization, debug symbols, or a language-standard flag when the project needs it:
gcc -Wall -Wextra -O2 -g -std=c17 hello.c -o hello
g++ -Wall -Wextra -O2 -g -std=c++20 hello.cpp -o hello_cpp
Successful compilation usually prints no output. If the compiler reports warnings, fix those before treating the build as clean.
Install Additional GCC Frontends on Arch Linux
GCC supports languages beyond C and C++ through additional frontend packages in the Arch core repository. Install only the frontends your project actually uses.
| Package | Language Frontend | Notes |
|---|---|---|
gcc-fortran | Fortran | Provides the GNU Fortran frontend |
gcc-ada | Ada (GNAT) | Provides the Ada frontend |
gcc-go | Go | Provides the GCC Go frontend |
gcc-d | D | Provides the D frontend |
gcc-objc | Objective-C | Provides Objective-C compiler support |
gcc-rust | Rust | Provides the GCC Rust frontend |
gcc-m2 | Modula-2 | Provides the Modula-2 frontend |
gcc-gcobol | COBOL | Provides the GCC COBOL frontend |
Install multiple frontends in a single command by listing them together:
sudo pacman -S gcc-fortran gcc-go
For a complete reference on GCC configuration and usage on Arch Linux, see the Arch Wiki GCC page.
Troubleshoot GCC on Arch Linux
GCC or G++ Command Not Found After Installation
If you see this error after installing GCC, the compiler package may be missing or your current shell may not have refreshed its command cache:
bash: gcc: command not found
Check the installed package and command paths first:
pacman -Q gcc
command -v gcc
command -v g++
Relevant output from a working install includes:
gcc 16.x.x /usr/bin/gcc /usr/bin/g++
If pacman -Q gcc returns error: package 'gcc' was not found, or if only gcc-libs is installed, install the compiler package again:
sudo pacman -S gcc
Linker Cannot Find a Required Library
This linker error means a required library is missing from your system. For example:
/usr/bin/ld: cannot find -lssl: No such file or directory
Use pacman -F to find which package provides the missing library file. If this is your first time using the file search, update the file database first:
sudo pacman -Fy
pacman -F usr/lib/libssl.so
The output shows which package owns that library path:
usr/lib/libssl.so is owned by core/openssl 3.x.x
Install the package listed in the results. In this example, the openssl package provides libssl.so:
sudo pacman -S openssl
Missing Header File During Compilation
This error appears when a header file referenced in your code is not installed. For example:
fatal error: curl/curl.h: No such file or directory
Search for the installed header path and install the corresponding package:
sudo pacman -Fy
pacman -F usr/include/curl/curl.h
The output identifies the package that provides the missing header:
usr/include/curl/curl.h is owned by core/curl 8.x.x
Install the package from the results:
sudo pacman -S curl
On Arch Linux, most packages include both runtime libraries and development headers in the same package, unlike Debian-based distributions that split them into separate -dev packages.
Need an Older GCC Branch Such as GCC 12
Arch’s official repositories track the current GCC branch and only package selected older compatibility branches. Check whether gcc12 exists before building a project around that branch:
pacman -Si gcc12
If gcc12 is unavailable in your enabled repositories, pacman returns:
error: package 'gcc12' was not found
Search the numbered GCC compatibility branches that are available before changing a build environment:
pacman -Ss '^gcc[0-9]'
When Arch packages a compatibility branch, the result uses a numbered package name such as:
extra/gcc15 15.x.x
The GNU Compiler Collection - C and C++ frontends (15.x.x)
Use the current gcc package unless a project documents a specific older compiler requirement. Avoid replacing /usr/bin/gcc manually; keep alternate toolchains isolated so pacman continues to own the system compiler.
Remove GCC from Arch Linux
Remove only the package set you actually installed. Pacman shows the transaction before applying it, so review the package list before confirming.
Remove the Standalone gcc Package
If you installed GCC as a standalone package, remove it with orphaned dependency cleanup:
sudo pacman -Rns gcc
Remove base-devel and GCC Build Tools
Removing
base-develcan also removemake,autoconf,automake, and other build tools when they are no longer required by another package. Only do this if you no longer need to compile software from source or build AUR packages.
If you installed base-devel for GCC and no longer need the build toolchain, remove both the meta package and the compiler:
sudo pacman -Rns base-devel gcc
Verify the package state after removal:
pacman -Q gcc base-devel
Expected output confirming removal:
error: package 'gcc' was not found error: package 'base-devel' was not found
Conclusion
GCC is available on Arch through pacman, with gcc covering C and C++ and base-devel adding the wider toolchain needed for AUR and source builds. Keep gcc-libs, older branch requirements, and optional frontends separate from the core compiler path so pacman remains the owner of the system toolchain.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><a href="https://example.com">link</a><blockquote>quote</blockquote>