AI Generated Cheatsheets

GCC Cheatsheet

Overview

GCC (GNU Compiler Collection) is a collection of programming language compilers, including C, C++, Objective-C, Fortran, Ada, and others.

Installation

Basic Usage

gcc file.c -o file

Compiles file.c and creates an executable named file.

Flags

Examples

gcc -c file.c -o file.o          # Compile source file to object file
gcc file.o -o file         # Link object file to create executable
gcc -Wall -Werror -g file.c -o file     # Compile with warnings and debugging information
gcc -O2 file.c -o file        # Compile with optimization
gcc -std=c99 file.c -o file         # Compile with C99 standard
gcc -I include/ file.c -o file       # Add include directory to include path
gcc -L lib/ -l mylib file.c -o file      # Link against library "mylib"

Resources