4
votes

I'm trying to make a simple "Hello World!" program in NetBeans IDE 7.3 with MinGW as my C++ compiler.

I'm getting build failures and I'm at a loss as to understanding why.

This is my compiler setup:

  • Family: MinGW
  • Base Directory: C:\MinGW
  • C Compiler: C:\MinGW\bin\gcc.exe
  • C++ Compiler: C:\MinGW\bin\g++.exe
  • Assembler: C:\MinGW\bin\as.exe
  • Make Command: C:\MinGW\msys\1.0\bin\make.exe
  • Debugger Command: C:\MinGW\bin\gdb.exe

I've made sure to that my environment PATH directs to C:\MinGW\bin and C:\MinGW\msys\1.0\bin.

My code is:

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello World!" << endl;
    return 0;
}

After trying to build the project, I recieve this message from the NetBeans debug output:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/NetBeansProjects/HelloWorld'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/helloworld.exe
make[2]: Entering directory `/c/NetBeansProjects/HelloWorld'
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]: g++: Command not found
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 127
make[2]: Leaving directory `/c/NetBeansProjects/HelloWorld'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/NetBeansProjects/HelloWorld'
make: *** [.build-impl] Error 2


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

I've search various Q&A, but I seem to be doing everything correctly.

3
Does C:\MinGW\bin\g++.exe exist? - Keith Thompson
Indeed it does. I'm rather baffled by this. - mumakurau
I haven't used NetBeans IDE. Perhaps it needs some specific configuration to find g++ and friends. Or, if you changed your PATH recently, perhaps NetBeans doesn't have your updated PATH; in that case, shutting down and restarting NetBeans might fix it. - Keith Thompson
None of your configured commands are being used - the location of make in your setup is C:\MinGW\msys\1.0\bin\make.exe, but the log shows that /usr/bin/make is being used; your setup indicates that the C++ compiler is C:\MinGW\bin\g++.exe, but g++ is being invoked (with no path). There's a major disconnect between your compiler setup and how the project is trying to build. - Michael Burr
Ah! That worked! I should have done so earlier. Thank you very much, Mr. Thompson! I'll continue my studies. - mumakurau

3 Answers

4
votes

Right click on My Computer and select properties. Click Advanced System Settings.System Properties dialog box will open. click Environmental Variables. Edit PATH variable and add C:\MinGW\msys\1.0\bin

1
votes

Your settings on netbeans shoud be as follows

Base Directory: C:\MinGW\bin 
C Compiler: C:\MinGW\bin\gcc.exe 
C++ Compiler: C:\MinGW\bin\g++.exe 
Fortran Compiler: C:\MinGW\bin\gfortran.exe 
Assembler: C:\MinGW\bin\as.exe 
Make Command: C:\MinGW\msys\1.0\bin\make.exe 
Debbuger Command: C:\MinGW\bin\gdb.exe

Add these to your Environment variables

C:\MinGW\bin and C:\MinGW\msys\1.0\bin

This can happen if you have set the settings on netbeans before/during the time of installing MINGW and setting the environment PATH.

Just restart netbeans

-2
votes

you download mysys form mingw or sourceforge.net after install it, path is C:\Mysys\1.0\bin\make.exe to give the path into make compiler in netbean ide.