Installing a Compiler
C source code is just text — nothing runs until a compiler turns it into a native executable. Before you write a single line of C, you need a working toolchain: a compiler, an assembler, and a linker, usually bundled together and invoked with a single command. This page walks through installing one on Windows, macOS, and Linux, and how to confirm it actually works.
The major C compilers
Compiler | Vendor | Platforms | Notes |
|---|---|---|---|
GCC | GNU Project | Linux, macOS, Windows (via MinGW/WSL) | The most widely used C compiler; ships by default on most Linux distributions. |
Clang | LLVM Project | Linux, macOS, Windows | Known for fast compiles and unusually readable error messages; the default on macOS. |
MSVC | Microsoft | Windows only | Bundled with Visual Studio; integrates tightly with Windows-specific tooling and debugging. |
All three understand standard C and produce native executables. As a beginner it does not matter much which one you pick — GCC and Clang are the two most common choices for learning, and this tutorial's examples work with either.
Windows
Windows does not ship a C compiler, so you have two solid options. The simplest for most learners is WSL (Windows Subsystem for Linux), which gives you a real Linux environment with GCC available through the package manager:
Inside WSL (Ubuntu)
sudo apt update sudo apt install build-essential
build-essential pulls in GCC, the standard C library headers, and make. If you prefer to stay on native Windows without WSL, install MinGW-w64, which provides a Windows-native build of GCC, then add its bin directory to your PATH so gcc is available from any terminal.
macOS
macOS includes Clang through the Xcode Command Line Tools, which you can install without downloading the full Xcode IDE:
xcode-select --install
This installs clang, make, and other common developer utilities. On macOS, running gcc from the terminal actually invokes Clang under the hood — Apple aliases the name for compatibility with scripts and Makefiles that expect it.
Linux
Most Linux distributions make installing GCC a one-line command. Debian and Ubuntu-based systems:
sudo apt install build-essential
Fedora and other RPM-based systems:
sudo dnf groupinstall 'Development Tools'
Arch Linux:
sudo pacman -S base-devel
Verifying the installation
Whichever platform you're on, confirm the compiler is installed and on your PATH by asking for its version:
gcc --version
gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions.
For Clang, the equivalent check is clang --version. If you see a version number instead of a "command not found" error, you're ready to compile your first program.
gcc --versionorclang --version— confirms the compiler is installed and callablewhich gcc(Linux/macOS) orwhere gcc(Windows) — shows exactly which binary is being usedRestart your terminal after installation if the command is still not found —
PATHchanges often need a fresh shell