Linux 即使生成文件和源代码存在,为什么 Eclipse Helios CDT 中的“构建项目”仍呈灰色显示?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5656252/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:38:57  来源:igfitidea点击:

Why is "Build Project" greyed-out in Eclipse Helios CDT even though the makefile and source exist?

clinuxeclipseeclipse-cdt

提问by Steve Emmerson

I can't build my project.

我无法构建我的项目。

I created a new CDT project in Eclipse Helios and told it to use existing source and makefile -- both, of which, appear correctly in the Package and Project views. The "Project" menu has both "Build All" and "Build Project" grayed-out, however, so it's impossible to build the project. "Build Automatically" is unchecked. During project creation, I told the wizard to use the Linux gcc(1) toolchain. I've been unable to find anything under Project->Properties or Window->Preferences that enables the "Build Project" feature. The Window->Preferences->Build display shows only one tab labeled "Error Parsers".

我在 Eclipse Helios 中创建了一个新的 CDT 项目,并告诉它使用现有的源代码和 makefile —— 这两者都正确地出现在 Package 和 Project 视图中。但是,“项目”菜单中的“全部构建”和“构建项目”都是灰色的,因此无法构建项目。“自动构建”未选中。在项目创建期间,我告诉向导使用 Linux gcc(1) 工具链。我一直无法在 Project->Properties 或 Window->Preferences 下找到启用“构建项目”功能的任何内容。Window->Preferences->Build 显示只显示一个标签为“Error Parsers”。

How can I enable the "Build Project" command?

如何启用“构建项目”命令?

回答by tamarintech

This may not be related to your issue if you're using a custom toolchain....

如果您使用的是自定义工具链,这可能与您的问题无关....

My experience with eclipse is that it sometimes doesn't quite grok the context of the file in the current editor. Have you tried right-clicking the project and selecting build there? Make sure you choose the actual project and not a source file. Also, make sure your source file is recently saved.

我对 eclipse 的经验是它有时并不能完全理解当前编辑器中文件的上下文。您是否尝试过右键单击该项目并在那里选择构建?确保选择实际项目而不是源文件。另外,请确保您的源文件是最近保存的。

Usually, after I use the method above then the correct "Run As" and "Build" options will appear regardless of the current active editor file. I have this issue with Java, JUnit, C/C++, etc with Helios on Linux.

通常,在我使用上述方法后,无论当前活动编辑器文件如何,都会出现正确的“运行方式”和“构建”选项。我在 Linux 上的 Helios 上遇到了 Java、JUnit、C/C++ 等问题。

回答by Steve Emmerson

I've discovered the cause of my problem: selecting the wrong "New Project" wizard. I selected the "Makefile Project with Existing Code" wizard because the source and makefile already existed. I should have selected the "C Project" wizard and told it not to create a makefile. The result of doing the latter is that the "Build Project" entry of the "Project" menu is not grayed-out.

我发现了问题的原因:选择了错误的“新建项目”向导。我选择了“Makefile Project with Existing Code”向导,因为源文件和 makefile 已经存在。我应该选择“C Project”向导并告诉它不要创建makefile。做后者的结果是“项目”菜单的“构建项目”条目没有变灰。

Apparently, the "Makefile Project with Existing code" is a generic wizard rather than one specific to C/C++ projects.

显然,“带有现有代码的 Makefile 项目”是一个通用向导,而不是特定于 C/C++ 项目的向导。

回答by Saidu

When you uncheck the

当您取消选中

Project :: Build Automatically

项目 :: 自动构建

button, then it will show you the option to

按钮,然后它会显示您的选项

Project :: Build All

项目 :: 全部构建