windows netbeans 中的 C++ 编译器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/854681/
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
C++ compiler error in netbeans
提问by Babiker
I've tried everything from reading the Netbeans help to browsing Google.
This code works fine in Dev-Cppbut not Netbeans 6.5.1. Netveans also places and exclamation mark next to #include <iostream>
which i checked and is in the include path of netbeans and is in the include folder:
我已经尝试了从阅读 Netbeans 帮助到浏览 Google 的所有方法。此代码在Dev-Cpp 中工作正常,但在Netbeans 6.5.1 中无效。Netveans 还在#include <iostream>
我检查的旁边放置了感叹号,它位于 netbeans 的包含路径中,并且位于包含文件夹中:
#include <iostream>
int main() {
std::cout << "Test" << "\n";
return (0);
}
My build tools are set to:
我的构建工具设置为:
Family: MinGW
家庭: MinGW
Base Directory: C:\Dev-Cpp\bin
基本目录:C:\Dev-Cpp\bin
C Compiler: C:\Dev-Cpp\bin\gcc.exe
C编译器:C:\Dev-Cpp\bin\gcc.exe
C++ Compiler: C:\Dev-Cpp\bin\g++.exe
C++ 编译器: C:\Dev-Cpp\bin\g++.exe
Fortran Compiler: C:\Dev-Cpp\bin\g77.exe
Fortran 编译器:C:\Dev-Cpp\bin\g77.exe
Make Command: C:\Dev-Cpp\bin\make.exe
制作命令:C:\Dev-Cpp\bin\make.exe
Debugger Command: C:\Dev-Cpp\bin\gdb.exe
调试器命令: C:\Dev-Cpp\bin\gdb.exe
I get error:
我得到错误:
Running "C:\Dev-Cpp\bin\make.exe -f Makefile CONF=Debug" in C:\Documents and Settings\Babiker\Desktop\Temp\Test
! was unexpected at this time.
C:\Dev-Cpp\bin\make.exe: *** [.validate-impl] Error 255
Build failed. Exit value 2.
采纳答案by akamch
The cause of the error is that Netbeans is incompatible with MinGW's make.
错误的原因是Netbeans 与MinGW 的make 不兼容。
You have a choice of supported make versions:
您可以选择支持的 make 版本:
- Cygwin's make. Cygwinis a blessing. It brings as much Unix to Windows as you'd like.
- MinGW's own MSYS, which "is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present". It is also a much smaller download than Cygwin.
回答by Tudor Luca
MinGW make tool in not compatible with NetBeans. Use msys make tool instead.
MinGW 制作工具与 NetBeans 不兼容。请改用 msys make 工具。
When you choose to use the make tool from msys, please be carefull to be installed in a path without spaces.
当您选择使用 msys 的 make 工具时,请注意安装在没有空格的路径中。
For example C:\Program Files\MinGW\msys\1.0\bin\make will fail. A good choice would be C:\MinGW\msys\1.0\bin\make.
例如 C:\Program Files\MinGW\msys\1.0\bin\make 将失败。一个不错的选择是 C:\MinGW\msys\1.0\bin\make。
回答by Chandan Pasunoori
i suggest you to use codeblocks compiler for netbeans i hope this will help you
我建议您为 netbeans 使用 codeblocks 编译器,希望这对您有所帮助
there is only a easy method to configure netBeans is first you download and install Code::Blocks IDE from Code::Blocks IDE Downlowdand MSYS 1.0.11
只有一种简单的方法来配置 netBeans 是首先从Code::Blocks IDE Downlowd和MSYS 1.0.11下载并安装 Code::Blocks IDE
all setting will automatically configured
所有设置将自动配置
but one thing you have to
但你必须做的一件事
select is make command
选择是 make 命令
from
从
C:\msys\1.0\bin\make.exe
C:\msys\1.0\bin\make.exe
i hope this help for you
我希望这对你有帮助
回答by lava
I tried running this code in netbeans 6.5 and it worked fine. I do not understand from the question how exclamation mark was added.
我尝试在 netbeans 6.5 中运行此代码并且运行良好。我从问题中不明白如何添加感叹号。
I suggest checking the linker options to ensure that netbeans is linking correctly to C++ standard library.
我建议检查链接器选项以确保 netbeans 正确链接到 C++ 标准库。
You can find this option by right click on project file -> properties.
您可以通过右键单击项目文件 -> 属性来找到此选项。
回答by Kevin Anderson
This may be irrelevant but you do have your make environment associated with the correct filetypes? So it's not trying to compile a .cpp file with the normal c-compiler or anything like that? I've never used your environment, but something like that is always possible I'd think.
这可能无关紧要,但您的 make 环境确实与正确的文件类型相关联?所以它不是试图用普通的 c 编译器或类似的东西编译 .cpp 文件?我从未使用过你的环境,但我认为这样的事情总是可能的。
And on that note, your code is IN a .cpp file, and not a .c file? Or maybe you have it in a .cxx file (I've seen that before for C++, rare, but I've seen it), and .cxx isn't associated with C++, so it "defaults" to C for unknown types?
在那一点上,您的代码在 .cpp 文件中,而不是 .c 文件中?或者,您可能在 .cxx 文件中拥有它(我之前在 C++ 中看到过,很少见,但我见过它),并且 .cxx 与 C++ 无关,因此对于未知类型,它“默认”为 C ?
Maybe seeing your makefile will also help offer some insight.
也许查看您的 makefile 也将有助于提供一些见解。