Menu

How to Install a C Compiler (GCC) on Windows, macOS, and Linux

Install a working C compiler on any system: MinGW-w64 on Windows, Apple's clang on macOS, and gcc on Linux - plus how to check the install worked and compile your first file.

This page includes runnable editors - edit, run, and see output instantly.

You can run every example in these docs right in the browser - each interactive block compiles and runs real C. But sooner or later you want C on your own machine, and for that you need a compiler: the program that turns your .c source files into an executable. This page installs one on each major system and verifies it works.

The compiler to have is GCC (the GNU Compiler Collection). It is free, it is what most tutorials, books, and build scripts assume, and its error messages are what other tools imitate. On macOS you will actually use clang, which Apple ships and aliases to the same gcc command - for everything in these docs the two behave identically.

Check What You Already Have

Before installing anything, open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS/Linux) and run:

gcc --version

If you see a version line such as gcc (GCC) 14.2.0, you are done - skip to compiling your first program. If the shell answers "command not found" (or Windows offers to search the Microsoft Store), follow your system's section below.

Windows: MinGW-w64 via MSYS2

Windows has no built-in C compiler. The standard way to get GCC is MinGW-w64, and the easiest maintained way to install it is the MSYS2 distribution:

  1. Download the MSYS2 installer from msys2.org and run it, accepting the default folder (C:\msys64).
  2. When the install finishes, open the MSYS2 UCRT64 terminal from the Start menu.
  3. Install the compiler package:
pacman -S mingw-w64-ucrt-x86_64-gcc
  1. Add the compiler to your PATH so every terminal can find it: open Settings → System → About → Advanced system settings → Environment Variables, edit the Path variable for your user, and add:
C:\msys64\ucrt64\bin
  1. Open a new Command Prompt (the PATH change does not reach terminals that are already open) and verify:
gcc --version

That is the whole toolchain - gcc, plus gdb and make are available from the same package system (pacman -S mingw-w64-ucrt-x86_64-gdb make) when you need them.

If you prefer an all-in-one route, installing Visual Studio Community with the "Desktop development with C++" workload also gives you a full C compiler (MSVC, invoked as cl), but the flags and error messages differ from what C tutorials show. For learning C, MinGW-w64's gcc matches the material.

macOS: Command Line Tools

Apple ships clang with its Command Line Tools, and one command installs them:

xcode-select --install

A dialog appears; accept it and let the download finish (a few minutes). You do not need the full Xcode app - the Command Line Tools alone include the compiler, make, and the system headers.

Verify:

gcc --version

The output says Apple clang rather than GCC - that is expected. Apple aliases gcc and cc to clang, and for standard C everything in these docs compiles the same. If you specifically want real GCC (rare for learning), brew install gcc adds it as gcc-14 alongside Apple's tools.

Linux: Your Package Manager

Most distributions leave the compiler out of the default install but keep it one command away.

Debian and Ubuntu (this also brings make and the standard headers):

sudo apt update && sudo apt install build-essential

Fedora:

sudo dnf install gcc

Arch:

sudo pacman -S gcc

Verify with gcc --version as above.

Compile Something to Prove It Works

Save this as hello.c:

#include <stdio.h>

int main(void) {
    printf("Hello, C!\n");
    return 0;
}

Then compile and run it:

gcc hello.c -o hello
./hello

On Windows the second command is hello (or .\hello in PowerShell). If the terminal prints Hello, C!, your toolchain works end to end. What those two commands actually do - and the flags worth turning on from day one - is the subject of Compile and Run C.

No Install: Run C in the Browser

While you are working through these docs, the built-in editor compiles and runs C without any setup:

Press Run to try it. Every concept page has blocks like this, so you can learn the language first and set up the toolchain when a project needs it.

Frequently Asked Questions

Which C compiler should I install?

GCC is the standard choice on Windows (via MinGW-w64) and Linux (via your package manager). On macOS, Apple ships clang and aliases it to the gcc command - it compiles standard C the same way, so the commands in tutorials work unchanged.

How do I install GCC on Windows?

Install MinGW-w64, most easily through MSYS2: install MSYS2 from msys2.org, open the UCRT64 terminal, run pacman -S mingw-w64-ucrt-x86_64-gcc, and add the ucrt64\bin folder to your PATH. Then gcc --version in a new terminal confirms it works.

Do I need to install anything to run C on a Mac?

Just the Command Line Tools: run xcode-select --install in Terminal and accept the prompt. That installs clang, which answers to both cc and gcc, plus make and the system headers. The full Xcode app is not required.

How do I check if a C compiler is already installed?

Open a terminal and run gcc --version (or cc --version). If you see a version number, you already have a compiler and can skip straight to compiling. If the command is not found, install one for your system first.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED