DEV Community

Nnamdi Okpala
Nnamdi Okpala

Posted on

How To Setup C Build Tools for Unix-Like Development on Windows (MSYS2 + GCC)

If you want a real Unix-like C/C++ development environment on Windows, one of the best setups is MSYS2 with the MinGW-w64 toolchain.

This gives you:

  • GCC and G++
  • Binutils
  • Make
  • GDB
  • Unix shell tooling
  • A package manager (pacman)
  • A workflow close to Linux development

This is the same type of environment many systems programmers, compiler developers, emulator developers, and operating system engineers use on Windows.


Step 1 — Install MSYS2

Download and install MSYS2 from:

After installation, open:

MSYS2 MINGW64
Enter fullscreen mode Exit fullscreen mode

Do not use regular CMD for this setup.


Step 2 — Update the System

Run:

pacman -Syu
Enter fullscreen mode Exit fullscreen mode

This updates the core MSYS2 packages.

Sometimes MSYS2 will ask you to close the terminal after the first update.

If that happens:

  1. Close the terminal
  2. Reopen MSYS2 MINGW64
  3. Continue with:
pacman -Su
Enter fullscreen mode Exit fullscreen mode

Step 3 — Install Build Essentials

Now install the Unix build tools:

pacman -S --needed base-devel mingw-w64-x86_64-toolchain
Enter fullscreen mode Exit fullscreen mode

This installs:

  • GCC
  • G++
  • Binutils
  • Make
  • GDB
  • Headers
  • Runtime libraries
  • pkg-config
  • Unix build utilities

When prompted:

Enter a selection (default=all):
Enter fullscreen mode Exit fullscreen mode

Just press:

Enter
Enter fullscreen mode Exit fullscreen mode

to install everything.


Step 4 — Verify Installation

Check the tools:

gcc --version
g++ --version
ld --version
make --version
gdb --version
Enter fullscreen mode Exit fullscreen mode

You should now see installed versions.

Example:

gcc (Rev10, Built by MSYS2 project) 16.x.x
Enter fullscreen mode Exit fullscreen mode

Step 5 — Compile Your First C Program

Create a file:

nano hello.c
Enter fullscreen mode Exit fullscreen mode

Paste:

#include <stdio.h>

int main() {
    printf("Hello from GCC on MSYS2\n");
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Save with:

CTRL + O
ENTER
CTRL + X
Enter fullscreen mode Exit fullscreen mode

Compile:

gcc hello.c -o hello.exe
Enter fullscreen mode Exit fullscreen mode

Run:

./hello.exe
Enter fullscreen mode Exit fullscreen mode

Output:

Hello from GCC on MSYS2
Enter fullscreen mode Exit fullscreen mode

Step 6 — Compile C++

Create:

nano hello.cpp
Enter fullscreen mode Exit fullscreen mode

Paste:

#include <iostream>

int main() {
    std::cout << "Hello C++" << std::endl;
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Compile:

g++ hello.cpp -o hello.exe
Enter fullscreen mode Exit fullscreen mode

Run:

./hello.exe
Enter fullscreen mode Exit fullscreen mode

What You Installed

GCC

The GNU Compiler Collection.

Used for:

  • C
  • C++
  • Objective-C
  • low-level systems programming

Binutils

The low-level binary tooling:

  • ld → linker
  • as → assembler
  • objdump
  • nm
  • ar

These tools are essential for:

  • OS development
  • reverse engineering
  • embedded systems
  • compiler work

Make

Build automation.

Example:

all:
    gcc main.c -o app
Enter fullscreen mode Exit fullscreen mode

Run with:

make
Enter fullscreen mode Exit fullscreen mode

GDB

The GNU Debugger.

Debug programs:

gdb ./hello.exe
Enter fullscreen mode Exit fullscreen mode

Why MSYS2 Is Powerful

MSYS2 gives Windows a Unix-style developer workflow.

You get:

  • Bash shell
  • Linux-like package management
  • GCC toolchains
  • POSIX tooling
  • easier open-source development

This is especially useful for:

  • compiler development
  • kernels
  • emulators
  • game engines
  • systems software
  • runtime environments
  • custom operating systems

Bonus — Useful Packages

Install Git:

pacman -S git
Enter fullscreen mode Exit fullscreen mode

Install CMake:

pacman -S mingw-w64-x86_64-cmake
Enter fullscreen mode Exit fullscreen mode

Install NASM:

pacman -S nasm
Enter fullscreen mode Exit fullscreen mode

Install Clang:

pacman -S mingw-w64-x86_64-clang
Enter fullscreen mode Exit fullscreen mode

Final Thoughts

Learning C build tooling is one of the most important steps toward understanding how software actually works underneath modern frameworks.

Once you understand:

  • compilers
  • assemblers
  • linkers
  • object files
  • runtimes
  • loaders

you stop treating software like magic.

You start seeing the machine underneath the abstraction.

Top comments (0)