C语言 Eclipse“Nothing to Build for Project”构建错误

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

Eclipse "Nothing to Build for Project" Error on Build

cbuildeclipse-cdtbuild-error

提问by Tchaikovsky

I realize this has been asked before, on this site and others, but none have provided a satisfactory answer. I'm just starting out with C/C++ and I'm using the Eclipse CDT on Mac. After creating a C project, then creating a source file (with the proper .cpp suffix), and writing a simple "Hello World!" program, I get the following error in the console: "Nothing to build for project [name]". There is nothing wrong with the code, as far as I know.

我意识到以前在本网站和其他网站上曾有人问过这个问题,但没有人提供令人满意的答案。我刚开始使用 C/C++,我在 Mac 上使用 Eclipse CDT。创建一个 C 项目后,然后创建一个源文件(带有正确的 .cpp 后缀),并编写一个简单的“Hello World!” 程序,我在控制台中收到以下错误:“没有为项目 [名称] 构建任何内容”。据我所知,代码没有任何问题。

#include <stdio.h> 

int main() {
    printf("Hello World");
}

I'm pretty sure there is nothing wrong with the gcc configuration or anything, although I am not entirely certain. The source file is saved and appears to be under the project, so I am not sure how to resolve this particular problem.

我很确定 gcc 配置或任何东西都没有问题,尽管我并不完全确定。源文件已保存并且似乎在项目下,因此我不确定如何解决此特定问题。

Any help is appreciated.

任何帮助表示赞赏。

回答by Tchaikovsky

The project would not build becauseit had the .cpp prefix, which implied a C++ file (in a C project). Everything worked when I changed it to .c.

该项目无法构建,因为它具有 .cpp 前缀,这意味着 C++ 文件(在 C 项目中)。当我将其更改为 .c 时,一切正常。

回答by Srianjanavadevoo Sureshkumar

In case of make error,go to project ->properties->c/c++ build->tool chain editor->select tools and select Cygwin C Compiler for C and Cygwin C++ Compiler for C++

如果出现make错误,进入项目->属性->c/c++构建->工具链编辑器->选择工具并选择Cygwin C Compiler for C和Cygwin C++ Compiler for C++