gcc is the GNU Compiler Collection, one of the foundational tools of the free-software world. Originally the "GNU C Compiler", it now compiles C, C++, Fortran, Ada, Go, Objective-C, and D. On most Linux systems gcc without arguments means the C compiler; g++ invokes the C++ driver.
gcc hello.c # compile to a.out
gcc -o hello hello.c # name the output
gcc -O2 -Wall -Wextra src.c # optimised, with warnings
gcc -g src.c # include debug info for gdb
gcc -c file.c # compile only (produce file.o)
gcc file1.o file2.o -o prog # link object files
GCC competes with clang (the LLVM-based compiler), which has better error messages and tooling but slightly different extension support. The Linux kernel is built with gcc by default; as of 2022 it can also be built with clang.
Discussed in:
- Chapter 1: Introduction: What Is Linux? — The Linux Ecosystem