GCC (GNU Compiler Collection)

GPL-3.0-or-later (with Runtime Library Exception)
Platform
Linux macOS Windows
Licence
GPL-3.0-or-later (with Runtime Library Exception) Open source
GCC (GNU Compiler Collection)

Overview

GCC — the GNU Compiler Collection — is the compiler suite that most of the free software world is built with. Started by Richard Stallman in 1987 as a C compiler for the GNU Project, it now compiles C, C++, Objective-C, Fortran, Ada, Go and D (with Modula-2 and COBOL in development) from a single driver, targeting more than 60 processor families from x86 and ARM to RISC-V and POWER. It is free software under the GNU General Public License v3 or later, with a Runtime Library Exception that allows the compiled output to be used in proprietary programs. GCC 16.2 is the current release; distributions ship their own maintained branches (Debian 13 ships 14.2, for example), and the development tree is mirrored at gcc-mirror/gcc.

Key Features

  • Many front ends, many targets — gcc, g++, gfortran, gnat and gccgo share one optimiser and code generator, and cross-compilation to embedded and exotic architectures is a first-class use case.
  • Mature optimisation pipeline — -O2 and -O3 enable decades of tuning: vectorisation (SIMD), link-time optimisation with -flto, profile-guided optimisation, and per-function target tuning.
  • Strong diagnostics — -Wall -Wextra catch real bugs, and newer releases add static analysis passes: -fanalyzer walks the code for leaks, double frees and null dereferences without an external tool.
  • Sanitizers — -fsanitize=address, undefined and thread instrument binaries to catch memory errors and data races at run time.
  • Hardening options built in — -D_FORTIFY_SOURCE=3, -fstack-protector-strong, -fPIE and -Wl,-z,relro are standard flags for building security-hardened system software.
  • Stable, portable ABI — the same source builds on Linux, BSD, macOS, Windows (MinGW-w64) and bare-metal targets, and GCC’s C++ ABI is the reference the rest of the toolchain tests against.
  • Open development — the compiler is developed on gcc.gnu.org mailing lists with a public git repository, a regression-testing CI, and release branches maintained for years.

Why Use GCC?

GCC is the default compiler of Linux distributions and the reference implementation for much of the C and C++ ecosystem, so code that builds with GCC builds almost everywhere. It is also the most portable compiler in existence: the same driver produces code for microcontrollers, mainframes and supercomputers, includes the Fortran and Ada compilers that scientific and safety-critical code depends on, and offers diagnostics and static-analysis passes that catch classes of bug a plain syntax check never sees. Because it is GPLv3 software with the Runtime Library Exception, there is no licence obstacle to shipping the binaries it produces, and every distribution has a maintained, security-patched branch available as a package.

Use Cases

  • Building Linux distributions, the kernel, and system libraries from source.
  • C and C++ application development where you want one toolchain across architectures.
  • Cross-compilation for embedded targets (ARM Cortex-M, AVR, RISC-V) with gcc-<triple> packages.
  • Scientific computing in Fortran and Ada, where GCC’s gfortran and GNAT are the reference compilers.
  • Security hardening and static analysis as part of a build pipeline (-fanalyzer, sanitizers, fortify flags).
  • Teaching and research into compilers: GCC’s source is a working example of an industrial optimiser.

Getting Started

Install the toolchain from your distribution — build-essential (Debian/Ubuntu), gcc gcc-c++ (Fedora/RHEL), or gcc via Homebrew or MinGW-w64 elsewhere. Check it with gcc --version, then compile and run a program in two commands: gcc -O2 -Wall hello.c -o hello and ./hello. For C++ use g++, and enable warnings and a debug build early: gcc -g -O0 -Wall -Wextra -fsanitize=address turns a crash into a line number. Use -flto for link-time optimisation in release builds, and -march=native only when the binary stays on the machine that built it.

Alternatives

  • Clang/LLVM — open source (Apache-2.0), modular, faster incremental builds, excellent diagnostics; often used alongside GCC rather than instead of it.
  • Zig — ships its own clang-based C/C++ compiler with cross-compilation built in.

Explore More Categories

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.