Installations for different platforms

Chapter 3: Installations for different platforms

Before writing your first line of C, you need a working compiler and toolchain. Because C is a systems language, the installation process varies significantly across operating systems.

I. Linux (Debian, Ubuntu, Fedora)

Linux is the native home of C. Most distributions come with gcc pre-installed, but you should install the complete development suite.

1. Ubuntu/Debian/Kali

sudo apt update
sudo apt install build-essential gdb

The build-essential package includes gcc, g++, make, and the standard C library headers.

2. Fedora/Red Hat

sudo dnf groupinstall "Development Tools" "Development Libraries"

II. macOS

macOS provides a specialized version of the Clang compiler as part of the Command Line Tools.

1. Installation via Terminal

Run the following command in your terminal:

xcode-select --install

This will open a pop-up window asking for permission to install the developer tools.

2. Verification

Even though you run gcc, macOS often aliases it to clang. You can verify this with:

gcc --version

III. Windows

Windows does not come with a C compiler by default. You have three main options depending on your goals.

1. MinGW-w64 (Native Development)

MinGW provides a Windows port of the GCC compiler. It is the best choice for beginners who want to use VSCode.

  • Download: Via MSYS2 (Recommended).
  • Setup: Install MSYS2, then run:
    pacman -S --needed base-devel mingw-w64-x86_64-toolchain
    

2. WSL2 (Windows Subsystem for Linux)

If you want to learn C for Linux but are on a Windows machine, WSL2 is the gold standard.

  • Install Ubuntu from the Microsoft Store.
  • Use the Linux instructions (Section I) inside the WSL terminal.

3. MSVC (Enterprise/Game Development)

If you plan to use Visual Studio (not VSCode), download the Visual Studio Community Edition and select the "Desktop development with C++" workload.

IV. Verifying the Toolchain

Once installed, ensure your compiler and debugger are in your system's PATH. Run these commands in your terminal:

CommandExpected OutputPurpose
gcc --versiongcc (Ubuntu 11.4.0-1ubuntu1~22.04) ...Check C Compiler
make --versionGNU Make 4.3 ...Check Build Automator
gdb --versionGNU gdb (Ubuntu 12.1-0ubuntu1) ...Check Debugger

Linuxapt installbuild-essentialmacOSxcode-select--installWindowsMSYS2 / MinGWor WSL2