Skip to main content

GCC C Compiler

1 min read Updated May 29, 2025
Share:
On this page (8sections)

GNU GCC Compiler

The GNU Compiler Collection (GCC) is the standard C compiler on Linux and macOS, and the recommended choice for modern C development on Windows via MinGW-w64 through MSYS2.

Official resources

  1. Download and install MSYS2 from https://www.msys2.org/
  2. Open MSYS2 UCRT64 from the Start menu
  3. Update packages: pacman -Syu
  4. Install GCC: pacman -S mingw-w64-ucrt-x86_64-gcc
  5. Verify: gcc --version

To use gcc from Command Prompt or PowerShell, add C:\msys64\ucrt64\bin to your Windows PATH (adjust if you installed MSYS2 elsewhere).

For a full toolchain (make, gdb, etc.): pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain

Linux

Most distributions include GCC in their package manager:

  • Debian / Ubuntu: sudo apt install build-essential
  • Fedora: sudo dnf install gcc
  • Arch: sudo pacman -S base-devel

Verify with gcc --version.

macOS

Install Xcode Command Line Tools (includes Clang, which supports C). For GCC specifically, install via Homebrew: brew install gcc

Quick test

#include <stdio.h>

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

Compile: gcc hello.c -o hello then run ./hello (or hello.exe on Windows).

Frequently Asked Questions

What does this C program do?
It is a C example program that demonstrates GCC C Compiler, including the complete source code and the expected sample output.
How do I compile and run this C program?
Save the code in a `.c` file, compile it with `gcc filename.c -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses core C syntax, illustrating a common pattern in C programming.

Related Tutorials

Search tutorials