Eclipse C++“没有构建”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18699782/
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
Eclipse C++ "Nothing to build" error
提问by Speedyard
I've been having a "nothing to build error" working with C++ in Eclipse. I have been unable to even get a simple "hello world" program, in a project named "hw," to run:
在 Eclipse 中使用 C++ 时,我一直遇到“没有构建错误”。我什至无法在名为“hw”的项目中运行一个简单的“hello world”程序:
#include <iostream>
using namespace std;
int main()
{
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
What is this "nothing to build" error? What does it mean? Why is it occurring? How do I fix it? I have checked what few leads I could find both here and elsewhere, but have thus far found nothing to help.
这个“无事可建”的错误是什么?这是什么意思?为什么会发生?我如何解决它?我已经检查了我可以在这里和其他地方找到的少数线索,但到目前为止没有发现任何帮助。
回答by butron
I had the same problem. I finally resolved everything by carefully following the directions for installing MinGW which require that you install the C and C++ compilers and MSYS basic syste, and MinGW developer toolk packages. Also make sure that C:\MinGW\bin;C:\MinGW\msys\1.0\bin are added to your Path system variables. Insuring all of these did the trick for me.
我有同样的问题。我最终通过仔细遵循安装 MinGW 的说明解决了所有问题,该说明要求您安装 C 和 C++ 编译器和 MSYS 基本系统以及 MinGW 开发人员工具包。还要确保将 C:\MinGW\bin;C:\MinGW\msys\1.0\bin 添加到您的 Path 系统变量中。确保所有这些都对我有用。
回答by Alex
I think the reason is the name of the source file. If you forget to give it a .cpp postfix it will generate this error. Good luck!
我认为原因是源文件的名称。如果你忘记给它一个 .cpp 后缀,它会产生这个错误。祝你好运!
回答by lmoglia
You can check if the project properties are ok. If you change the source code location and do not refresh this project property, probably the compiler will not find it. You can check this as follows:
您可以检查项目属性是否正常。如果更改源代码位置并且不刷新此项目属性,则编译器可能找不到它。您可以按如下方式检查:
Right click on Project folder -> C/C++ General -> Paths and Symbols -> Source Location (just in case)
右键单击项目文件夹 -> C/C++ General -> Paths and Symbols -> Source Location(以防万一)
回答by S1L1K0N
I had the same issue, couldn't get anything to build. I had MinGW installed in the default directory and had to modify my path settings as well. Instructions on changing your path variable can be found http://www.computerhope.com/issues/ch000549.htm
我有同样的问题,无法构建任何东西。我将 MinGW 安装在默认目录中,并且还必须修改我的路径设置。可以在http://www.computerhope.com/issues/ch000549.htm找到有关更改路径变量的说明
回答by S1L1K0N
I know the answer was directed at a C++ application but the problem also manifests itself if you import a project into a C project that has files that have an upper case trailing C in the filename. For example if any files exist as FileName.C the above error will be printed.
我知道答案是针对 C++ 应用程序的,但如果您将项目导入到 C 项目中,该项目的文件名中带有大写尾随 C,则问题也会显现出来。例如,如果任何文件作为 FileName.C 存在,则会打印上述错误。
Simply changing all the files so that they have a lower case 'c' will fix the problem. That is FileName.C becomes FileName.c. This has caught me twice now!
只需将所有文件更改为小写字母“c”即可解决问题。即 FileName.C 变成 FileName.c。这已经抓住了我两次!
I hope this helps.
我希望这有帮助。
回答by FORSAK3N
I had a similar problem and I think that there are a few words that cannot be used in file names.
我遇到了类似的问题,我认为文件名中不能使用一些单词。
I installed Eclipse Mars and MinGW on Windows 7, then opened eclipse to run the classic "Hello World" program and it successfully built, and ran.
我在 Windows 7 上安装了 Eclipse Mars 和 MinGW,然后打开 eclipse 运行经典的“Hello World”程序,它成功构建并运行。
So, I created new project "OutPutText" and ran the same code as the "Hello World" and I got the “Nothing to build” error.
因此,我创建了新项目“OutPutText”并运行与“Hello World”相同的代码,但出现“Nothing to build”错误。
Then I myself tried some stupid permutation and combinations of project name. I found out that if I add the word "text" to the name of the file the error comes back and if I don't it runs fine!
然后我自己尝试了一些愚蠢的项目名称排列和组合。我发现如果我在文件名中添加“文本”这个词,错误就会回来,如果我不这样做,它运行良好!
I tested even more and found that this particular name "OutPuttingText" is causing the problem but not "OutPut Text" or "OutPutting Text" or "OutPut" as file names.
我进行了更多测试,发现这个特定名称“OutPuttingText”导致了问题,而不是“OutPut Text”或“OutPutting Text”或“OutPut”作为文件名。
回答by oodes
Ensure your virus protection is disabled before installing the compiler minGW. This is what was causing my identical problem. The virus protection can prevent some dll files from being installed and this error won't be flagged up which is what caused my problems. After installing minGW (without virus protection), re-install eclipse (I used mars2) and it worked fine.
确保在安装编译器 minGW 之前禁用病毒防护。这就是导致我的相同问题的原因。病毒防护可以阻止安装某些 dll 文件,并且不会标记此错误,这就是导致我出现问题的原因。安装minGW(没有病毒防护)后,重新安装eclipse(我用的是mars2),它运行良好。
Prior to this I had searched every similar thread but nothing worked. Hope this helps someone else.
在此之前,我搜索了每个类似的线程,但没有任何效果。希望这对其他人有帮助。
回答by Rut.b
enter to Project-> Properties -> Project Natures and addC Nature (should be two enters of "C nature")
进入Project-> Properties -> Project Natures并添加C Nature(应该是“C自然”的两个入口)