Course contentsShow
← C
Lesson 11 of 1,2191. FoundationsFree lesson

Setting up MinGW on Windows

Setting up MinGW on Windows

What you'll learn: How to install the MinGW-w64 compiler so your computer can translate C code into working programs.

The Translator for Your Computer

Think of your computer as a high-speed worker who only speaks a language called "Machine Code" (long strings of ones and zeros). You, the programmer, speak C. To get the worker to do anything, you need a middleman to translate your C files into those ones and zeros. On Windows, the most popular free "translator" for this job is MinGW (Minimalist GNU for Windows).

Without MinGW, your computer sees a .c file as just a plain text document, like a grocery list. With it, those text files become functional .exe programs.

Step 1: Installation

The simplest way to get MinGW is through a project called MSYS2, which manages the installation for you.

  1. Download the installer from msys2.org.
  2. Follow the setup wizard, then open the terminal window it provides (it looks like a black box).
  3. Type this command: pacman -S mingw-w64-ucrt-x86_64-gcc and hit Enter.
  4. Follow the prompts to finish the installation.

Step 2: Setting the Path

Installing the tool is like buying a new power tool and putting it in a shed. If you want to use it from anywhere in your yard (or in any folder on your computer), you need to tell Windows exactly where that shed is.

  1. Search for "Edit the system environment variables" in your Start menu.
  2. Click Environment Variables, find the Path variable under "System variables," and click Edit.
  3. Add the location where MinGW was installed (usually C:\msys64\ucrt64\bin).

Step 3: The Verification

To make sure your "translator" is ready for work, open a new Command Prompt and type:

gcc --version

If you see a wall of text starting with "gcc (Rev...)", congratulations! You’ve successfully linked your human-readable logic to your computer’s binary brain. You are now ready to compile your first program.

Key takeaway

MinGW is the compiler that turns your C text into executable programs, but you must add it to your System Path so your computer can find it.