无法在 NetBeans 7.0 上编译 C++ 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5803126/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't Compile C++ Code on NetBeans 7.0
提问by daGrevis
I just installed NetBeans 7.0 with C++ package. It asked for C++ compiler - I installed MinGW. I added it to NetBeans (so it recognize it). I think that it's all correct...
我刚刚安装了带有 C++ 包的 NetBeans 7.0。它要求 C++ 编译器 - 我安装了 MinGW。我将它添加到 NetBeans(因此它可以识别它)。我觉得都是对的...
I wrote very simple C++ application in main.cppand tried to compile it...
我在main.cpp 中编写了非常简单的 C++ 应用程序并尝试编译它...
#include <cstdlib>
#include <iostream>
int main( int argc, char** argv ) {
std::cout << "Hello, world!";
return 0;
}
It complains about "Make Command" (under Tools -> Options -> C/C++ -> Build Tools). I tried to fix it and type C:\MinGW\msys\1.0\bin\make.exein there. I tried to compile it again! Here's the error message...
它抱怨“Make Command”(在工具 -> 选项 -> C/C++ -> 构建工具下)。我试图修复它并在其中键入C:\MinGW\msys\1.0\bin\make.exe。我再次尝试编译它!这是错误信息...
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf make[1]: Entering directory `/c/Users/admin/Documents/C++/helloWorld' "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/helloworld.exe make[2]: Entering directory `/c/Users/admin/Documents/C++/helloWorld' make[2]: mkdir: Command not found mkdir -p build/Debug/MinGW-Windows make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 127 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 make[2]: Leaving directory `/c/Users/admin/Documents/C++/helloWorld' make[1]: Leaving directory `/c/Users/admin/Documents/C++/helloWorld' BUILD FAILED (exit value 2, total time: 2s)
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf make[1]: Entering directory `/c/Users/admin/Documents/C++/helloWorld' "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/helloworld.exe make[2]: Entering directory `/c/Users/admin/Documents/C++/helloWorld' make[2]: mkdir: Command not found mkdir -p build/Debug/MinGW-Windows make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 127 make[1]: *** [.build-conf] Error 2 make: *** [.build-impl] Error 2 make[2]: Leaving directory `/c/Users/admin/Documents/C++/helloWorld' make[1]: Leaving directory `/c/Users/admin/Documents/C++/helloWorld' BUILD FAILED (exit value 2, total time: 2s)
How to fix it and configure NetBeans (with C++ package) correctly?
如何修复它并正确配置 NetBeans(使用 C++ 包)?
回答by evnu
I guess you didn't add msys to your PATH
variable. See this entry in the Netbeans forum, as the error reported there is essentially the same as the one you pasted in your question. So, the error message you received does not complain about make, it complains that it can't find mkdir
, which is supposed to be in a directory in your msys directory. Adding C:\MinGW\msys\1.0\bin\
to your windows PATH
variable will probably be sufficient to fix this.
我猜您没有将 msys 添加到您的PATH
变量中。请参阅Netbeans 论坛中的此条目,因为那里报告的错误与您在问题中粘贴的错误基本相同。因此,您收到的错误消息不是抱怨 make ,而是抱怨它找不到mkdir
,它应该在您的 msys 目录中的目录中。添加C:\MinGW\msys\1.0\bin\
到您的 windowsPATH
变量可能足以解决此问题。
回答by daGrevis
mkdir in Cygwin may be a separate .exe instead of a function of bash. So you may be just missing it for some reason.
Cygwin 中的 mkdir 可能是一个单独的 .exe 而不是 bash 的函数。所以你可能只是因为某种原因错过了它。
回答by user4301647
"Resolve Missing Native Build Tools" Netbeans Make command problem. Go to -Tools -Options -C/C++ Write to Make Command: C:\MinGW\msys\1.0\bin\make.exe
“解决缺少的本机构建工具” Netbeans Make 命令问题。转到 -Tools -Options -C/C++ Write to Make 命令:C:\MinGW\msys\1.0\bin\make.exe
回答by user3652388
Solution
Copy mingw32-make.exe
from MinGW\bin\
to msys
folder, replacing make.exe
解决方案复制mingw32-make.exe
从MinGW\bin\
到msys
文件夹,替换make.exe
not sure why this is necessary but, hey, it worked.
不知道为什么这是必要的,但是,嘿,它起作用了。