简体   繁体   English

无法使用MinGW C ++在NetBeans IDE 7.3中编译“Hello World”

[英]Cannot Compile “Hello World” in NetBeans IDE 7.3 with MinGW C++

I'm trying to make a simple "Hello World!" 我想做一个简单的“Hello World!” program in NetBeans IDE 7.3 with MinGW as my C++ compiler. 使用MinGW作为我的C ++编译器的NetBeans IDE 7.3中的程序。

I'm getting build failures and I'm at a loss as to understanding why. 我遇到了构建失败,我不知道为什么会这样做。

This is my compiler setup: 这是我的编译器设置:

  • Family: MinGW 家庭: MinGW
  • Base Directory: C:\\MinGW 基本目录: C:\\ MinGW
  • C Compiler: C:\\MinGW\\bin\\gcc.exe C编译器: C:\\ MinGW \\ bin \\ gcc.exe
  • C++ Compiler: C:\\MinGW\\bin\\g++.exe C ++编译器: C:\\ MinGW \\ bin \\ g ++。exe
  • Assembler: C:\\MinGW\\bin\\as.exe 汇编程序: C:\\ MinGW \\ bin \\ as.exe
  • Make Command: C:\\MinGW\\msys\\1.0\\bin\\make.exe Make命令: C:\\ MinGW \\ msys \\ 1.0 \\ bin \\ make.exe
  • Debugger Command: C:\\MinGW\\bin\\gdb.exe 调试器命令: 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 . 我已经确保我的环境PATH指向C:\\ MinGW \\ binC:\\ 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: 在尝试构建项目之后,我从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)

I've search various Q&A, but I seem to be doing everything correctly. 我搜索各种问答,但我似乎正在做正确的事情。

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 编辑PATH变量并添加C:\\ MinGW \\ msys \\ 1.0 \\ bin

Your settings on netbeans shoud be as follows 您在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

Add these to your Environment variables 将这些添加到您的Environment变量中

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. 如果您在安装MINGW之前/期间设置netbeans设置并设置环境PATH,则会发生这种情况。

Just restart netbeans 只需重启netbeans即可

你安装后下载mysys表格mingw或sourceforge.net,路径是C:\\ Mysys \\ 1.0 \\ bin \\ make.exe给netbean ide中的make编译器路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM