CInstalling a Compiler

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)

Bash
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:

Bash
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:

Bash
sudo apt install build-essential

Fedora and other RPM-based systems:

Bash
sudo dnf groupinstall 'Development Tools'

Arch Linux:

Bash
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:

Bash
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 --version or clang --version — confirms the compiler is installed and callable

  • which gcc (Linux/macOS) or where gcc (Windows) — shows exactly which binary is being used

  • Restart your terminal after installation if the command is still not found — PATH changes often need a fresh shell

Pick one and move on
Don't spend too long deciding between GCC and Clang as a beginner. Install whichever is easiest on your platform (usually GCC on Linux/Windows, Clang on macOS) and start writing code — you can always install the other later.
Multiple compilers can coexist
It's completely normal to have both GCC and Clang installed on the same machine. They read the same C source files and mostly accept the same command-line flags, so switching between them later is low-friction.