MinGW (Minimalist GNU for Windows) is a popular compiler suite that allows you to compile C and C++ programs on Windows systems. Here’s a complete walkthrough to get you started:
Step 1: Download MinGW
- Visit the Official Website
- Go to MinGW’s SourceForge page
- Click the Download button to get the installer (
mingw-get-setup.exe
).
- Run the Installer
- Open the downloaded
.exe
file. - Follow the setup wizard (default settings are fine).
- Open the downloaded
Step 2: Install Required Packages
- Launch the MinGW Installation Manager
- After installation, open MinGW Installer.
- Select Essential Packages
- Under Basic Setup, check:
mingw32-base
(C compiler)mingw32-gcc-g++
(C++ compiler)mingw32-gcc-objc
(Objective-C, optional)
- Right-click each and choose Mark for Installation.
- Under Basic Setup, check:
- Apply Changes
- Go to Installation → Apply Changes and confirm.
Step 3: Add MinGW to System PATH
- Locate the Installation Directory
- Typically at
C:\MinGW\bin
.
- Typically at
- Update PATH Environment Variable
- Press
Win + R
, typesysdm.cpl
, and go to Advanced → Environment Variables. - Under System Variables, find
PATH
, click Edit, and add:C:\MinGW\bin
- Click OK to save.
- Press
Step 4: Verify Installation
- Open Command Prompt (
Win + R
→cmd
) - Check GCC Version
gcc --version
If installed correctly, you’ll see version details.
Hello World!
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}