Wednesday, August 29, 2012

Configure NetBeans 7.x C++ compiler (MinGW)

Alright, the reason you are here is clear. You are having trouble setting the C++ compiler correctly with NetBeans 7.x on Windows platform. No worries, it's an easy fix.

First, we need the MinGW compiler package. Head on to to get the latest version.
You may see another version, of course newer than the one in the above image.
Open up the .exe file you just downloaded, and proceed with it's installation. You will encounter a dialog which asks you if you want the pre-packaged repository catalogues, or download the newest ones. It's always better to download the latest catalogue.

You may proceed with the installation. Few steps ahead, you will be asked which compilers you want downloaded and installed. Check C, C++ and MSYS Basic System.

Continue the installation.
The installer will download and install the newest MinGW and MSYS components.

After it's finished, open Computer, right click on some empty spot, and press Properties. Or, open Computer, and click System properties in the menu-bar.
Go to Advanced system settings, Environment Variables, in the System Variables list, find the variable Path.
Now, double click it, and put your cursor at the end of the Value textbox.
Add semicolon right after the last character (only if it isn't another semicolon, in which case you just paste the directory) and paste the location of the MinGW bin directory (Usually C:\MinGW\bin). Now add another semicolon after the MinGW bin directory, and paste the MSYS bin directory (Usually C:\MinGW\msys\1.0\bin).

Press OK on both dialogs, and open NetBeans.

Go to Tools-> Options-> C/C++, and press the Add button which is found below the Tool Collection panel.
For the Base Directory select the MinGW bin folder, and press OK.

After this step, NetBeans should recognize and select automatically all the needed compilers, except the "make" command. If you select the mingw32-make.exe file, it will be refused.
The make.exe file is found in the MSYS bin directory. 
Press OK to close this dialog, and restart NetBeans. Your adding of C++ compiler to NetBeans 7.x is completed.

If you have any problems with the setup, feel free to post it here.


Unknown on September 8, 2012 at 4:44 PM said...


after having done everything you told on this page, i get :

make[2]: mkdir: Command not found
make[2]: *** [build/Debug/MinGW_2-Windows/main.o] Error 127
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)

What I did was :
new project => new file => test project => run project.

hope you can help me out.

WinBro on September 8, 2012 at 9:38 PM said...

By the looks of the error, it seems that NetBeans can't find the make command. I tried, but couldn't reproduce the same error. I would say, check the PATH variable again, and restart NetBeans.
Hope that will help.

Ann said...

I have followed the steps as mentioned and successfully installed the compiler. However, after creating my first code, which was only a hello world program, I received this :

"/usr/bin/make" -f nbproject/ QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/mingw/bin/MyFirstCPP'
"/usr/bin/make" -f nbproject/ dist/Debug/MinGW-Windows/myfirstcpp.exe
make[2]: Entering directory `/mingw/bin/MyFirstCPP'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make[2]: Leaving directory `/mingw/bin/MyFirstCPP'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/mingw/bin/MyFirstCPP'
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 767ms)

Please help me to correct this. Thanks in advance.

Program Novice said...

hi winbro,

i have a problem where, after writing the code, the cursor on the output screen (terminal container window) becomes static, like a small blackened cursor and i can't key-in any input.

i was just writing a simple code with basic cin and cout stuff.

any idea on what is going on here, or any missing things here?

WinBro on March 8, 2013 at 9:11 PM said...

I googled your error, and as far as I see, this is the one that looks mostly like yours.

The solution would be to download this file and put it in your Project's directory.

@Program Novice
I can't seem to find anything that resembles that problem. Maybe you have a pending empty cin you need to enter before actually you enter your needed input.

anand said...

just as u told. wrked for me.

vini on June 10, 2013 at 3:49 PM said...

Worked fo me ! Thank you

John on January 8, 2014 at 11:54 PM said...

I did everything you said except at the part where you go Tools->Options->C/C++ and when i enter the folder it says "No Compiler sets were found in the directory C:\MinGw\bin"

My Blog' Lets Try on March 1, 2014 at 10:11 PM said...

Hi All I have a problem, i can't run my project.....
this is the error report....

"/C/FPC/2.6.0/bin/i386-Win32/make.exe" -f nbproject/ QMAKE= SUBPROJECTS= .build-conf
/usr/bin/sh: /C/FPC/2.6.0/bin/i386-Win32/make.exe: No such file or directory
make: *** [.build-impl] Error 127

BUILD FAILED (exit value 2, total time: 551ms)

please help me...^_^

Anonymous said...

You should really look at the link you put to download MinGW and add more instruction because the installer manager of the newer version is not good and I have no idea what to download.

WinBro on May 20, 2015 at 6:43 PM said...

@Anonymous last comment: I stopped working with NetBeans long time ago, and I guess I won't be updating this tutorial anymore, sorry.

Post a Comment


WindowsBro | Windows tips, fixes, help.. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com