[英]Cannot Compile “Hello World” in NetBeans IDE 7.3 with MinGW C++
我想做一個簡單的“Hello World!” 使用MinGW作為我的C ++編譯器的NetBeans IDE 7.3中的程序。
我遇到了構建失敗,我不知道為什么會這樣做。
這是我的編譯器設置:
我已經確保我的環境PATH指向C:\\ MinGW \\ bin和C:\\ MinGW \\ msys \\ 1.0 \\ bin 。
我的代碼是:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
在嘗試構建項目之后,我從NetBeans調試輸出中收到此消息:
"/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)
我搜索各種問答,但我似乎正在做正確的事情。
右鍵單擊“我的電腦”,然后選擇屬性。 單擊“高級系統設置”。將打開“系統屬性”對話框。 單擊環境變量。 編輯PATH變量並添加C:\\ MinGW \\ msys \\ 1.0 \\ bin
您在netbeans上的設置應如下所示
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
將這些添加到您的Environment變量中
C:\MinGW\bin and C:\MinGW\msys\1.0\bin
如果您在安裝MINGW之前/期間設置netbeans設置並設置環境PATH,則會發生這種情況。
只需重啟netbeans即可
你安裝后下載mysys表格mingw或sourceforge.net,路徑是C:\\ Mysys \\ 1.0 \\ bin \\ make.exe給netbean ide中的make編譯器路徑。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.