How to Install MinGW Compiler on Windows Platforms

C/C++ is a general-purpose, mid-level programming language. To get started with C/C++ language we need to install MinGW compiler or an IDE (Integrated development Environment) such as Codeblock, Dev C++ etc.

C and C++ uses same compiler as C++ is a superset of C language only few programs that may compile in C, but not in C++.

Before writing programs we need a compiler installed on your computer. We can use compiler using command prompt and IDE as mention earlier. In this article you will study both ways of compiling your code.

Finding the best Compiler:

There are many compiler available to download and install both free and paid. Some of the compilers are Codeblocks, Dev C++, Visual studio, Netbeans, Turbo C++ etc. And there are many online compiler like,, codechef which you can use if don’t want to install anything.

Note: We use Codeblocks compiled program on

Warning: If you are beginner don’t use Turbo C++. You endup hating programming with this compiler.

So lets install MinGW on you local environment and all other IDE will be explained in next article.

How to Install MinGW Tools on Windows

1. Download MinGW Tools and Double click the downloaded file to install.

2. A window popup asking you to change directory ( change if you want or leave it)

3. Then click install and click continue

install minGW compiler 1
MinGW tools Installation

4. Again a new popup window opens asking you to select required component

5. Click the tick box and select mark for installation to base-bin, gcc-g++-bin, and gcc-obj-bin (you can also select all).

6. From main menu click on Installation>> apply changes and again click Apply. Wait for minute to install than click close.

install minGW compiler
MinGW installation

MinGW compiler is installed on your computer. Now you have set path variable for compiler.

1. Open directory where you installed MinGW>> bin folder and copy the path (for example: C:\MinGW\bin).

2. Now right click on MY-COMPUTER on desktop. Select Properties >> Advance system setting.

3. Click on Environment variable in popup window and click on PATH >> Edit from below options.

install minGW compiler 3
Set compiler path variable

4. Click on New and paste the directory path (C:\MinGW\bin) and click three times OK to exit.

install minGW compiler 4
set path variable

Now it’s done compiler installed and path is set

Let’s Verify compiler

Open command prompt and type gcc hit enter.  If it shows:

GCC: fatal error: no input file 
Compilation terminate

it means everything installed and set properly. Refer below image

Try simple C program Example

  • Open notepad and Copy above code to notepad and save it to desktop for easy access as example.c extension

int main()

return 0;
  • Now open command prompt.
  • Type > > cd desktop
  • Changed directory look like this C:\Users\xxxxx\Desktop>
  • Type gcc –o example.exe example.c.
  • Hit enter
  • Program got compiled now you can see a example.exe file on your desktop
  • Type example.exe in CMD to see output
install minGW compiler 5
C program example

Example of C++ program

  • Copy below program to notepad and save it to desktop with .cpp extension
using namespace std;

int main()
cout< <"";

return 0;
  • Open command prompt
  • Type > > cd desktop
  • Directory look like this C:\Users\xxxxx\Desktop>
  • Type g++ –o example2.exe example2.cpp.
  • Hit enter
  • Program got compiled
  • Type example2.exe to see output
install minGW compiler 6
C++ program example

Comeback after to see installation of IDE compilers on windows, mac and Linux platforms.

Don’t forget to give your feedback.


  1. Hello, thanks for the article.

    I followed your instructions and watched many youtube videos on how to setup mingw for c++, but every time while downloading, I get errors related to failed mingw packages. Please, what do I do?


  2. after I open the Command prompt and type in gcc, it shows me the following:-
    ‘gcc’ is not recognized as an internal or external command,
    operable program or batch file.

    Please help!

Leave a Reply

Your email address will not be published. Required fields are marked *