C++ Eclipse CDT:没有将所有目标设为目标的规则

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

Eclipse CDT: no rule to make target all

c++eclipseeclipse-cdt

提问by Mark Z.

My Eclipse CDT keeps complaining "make: *** no rule to make target all" when I am trying to compile the piece of code below:

当我尝试编译下面的代码时,我的 Eclipse CDT 一直抱怨“make: *** no rule to make target all”:

#include <iostream>
using namespace std;

int main() {
  cout << "Hello World!!!" << endl; // prints Hello World!!!
  return 0;
}

Anyone knows how to solve this? I have read the post with the similar title: make: *** No rule to make target `all'. Stop. Eclipse errorBut none of those answers help...

有谁知道如何解决这个问题?我读过类似标题的帖子: make: *** No rule to make target `all'。停止。Eclipse 错误但这些答案都没有帮助...

Thanks a lot!

非常感谢!

回答by ScoPi

You need to change your project settings so that Eclipse-CDT manages your Makefiles for you.

您需要更改项目设置,以便 Eclipse-CDT 为您管理 Makefile。

  1. Select Project->Properties from the menu bar.
  2. Click C/C++ Build on the left in the dialog that comes up.
  3. Under the Builder Settings tab on the right, select "Generate Makefiles automatically" under the Makefile generation section.
  4. Hit OK and build again.
  1. 从菜单栏中选择 Project->Properties。
  2. 在出现的对话框中单击左侧的 C/C++ Build。
  3. 在右侧的 Builder Settings 选项卡下,选择 Makefile generation 部分下的“Generate Makefiles automatically”。
  4. 点击确定并再次构建。

回答by user1146300

"all" is a default setting, even though Behaviour->Build (Incremental build) tab has no variable. I solved as

“all”是默认设置,即使 Behaviour->Build (Incremental build) 选项卡没有变量。我解决了

  1. Go to Project Properties > C/C++ Build > Behaviour Tab.
  2. Leave Build (Incremental Build) Checked.
  3. Enter "test" in the text box next to Build (Incremental Build).
  4. Build Project. You will see error message.
  5. Go back to Build (Incremental Build) and delete "test".
  6. Build Project.
  1. 转到项目属性 > C/C++ 构建 > 行为选项卡。
  2. 选中构建(增量构建)。
  3. 在 Build (Incremental Build) 旁边的文本框中输入“test”。
  4. 构建项目。您将看到错误消息。
  5. 返回Build(增量构建)并删除“test”。
  6. 构建项目。

回答by raptoravis

  1. Select Project->Properties from the menu bar.

  2. Click C/C++ Build on the left in the dialog that comes up.

  3. Under the Builder Settings tab on the right, check and make sure the "Build location" is correct.
  1. 从菜单栏中选择 Project->Properties。

  2. 在出现的对话框中单击左侧的 C/C++ Build。

  3. 在右侧的 Builder Settings 选项卡下,检查并确保“Build location”正确。

回答by wall-e

In C/C++ Build -> Builder Settings, select Internal builder (instead of External builder).

在 C/C++ 构建 -> 构建器设置中,选择内部构建器(而不是外部构建器)。

It works for me.

这个对我有用。

回答by drmuelr

I just solved this exact issue for myself; even referenced this question.

我刚刚为自己解决了这个确切的问题;甚至引用了这个问题。

I'm assuming you haven't written the "all" rule that Eclipse is complaining about. If this is the case, take these steps:

我假设您还没有编写 Eclipse 抱怨的“全部”规则。如果是这种情况,请执行以下步骤:

  1. Go to Project Properties > C/C++ Build > Behaviour Tab.
  2. Leave Build (Incremental Build) Checked.
  3. Remove "all" from the text box next to Build (Incremental Build).
  4. Compile away!
  1. 转到项目属性 > C/C++ 构建 > 行为选项卡。
  2. 选中构建(增量构建)。
  3. 从 Build (Incremental Build) 旁边的文本框中删除“all”。
  4. 编译离开!

This lets Eclipse know you aren't trying to use a make target called "all". For some reason, that is the default.

这让 Eclipse 知道您没有尝试使用名为“all”的 make 目标。出于某种原因,这是默认设置。

回答by Dang_Ho

You have 2 cases

你有2个案例

  • If you create Makefile by yourself, go to
  • 如果您自己创建 Makefile,请转到
  1. Select Project->Properties from the menu bar.
  2. Click C/C++ Build on the left in the dialog that comes up.
  3. Disable generate makefile automatically -> Under the Builder Settings tab on the right, check and make sure the "Build location" is correct (That location is where your Makefile)
  1. 从菜单栏中选择 Project->Properties。
  2. 在出现的对话框中单击左侧的 C/C++ Build。
  3. 禁用自动生成 makefile -> 在右侧的 Builder Settings 选项卡下,检查并确保“Build location”正确(该位置是您的 Makefile 所在的位置)
  • If you don't have Makefile -> You need Eclipse DS-5 to help you create Makefile
  • 如果你没有 Makefile -> 你需要 Eclipse DS-5 来帮助你创建 Makefile
  1. Select Project->Properties from the menu bar.
  2. Click C/C++ Build on the left in the dialog that comes up.
  3. Enable generate makefile automatically
  1. 从菜单栏中选择 Project->Properties。
  2. 在出现的对话框中单击左侧的 C/C++ Build。
  3. 启用自动生成makefile

I advise you create Makefile by your self

我建议你自己创建 Makefile

回答by bilalraja

Sometimes if you are making a target via make files double check that all c files are named correctly with correct file structure.

有时,如果您通过 make files 制作目标,请仔细检查所有 c 文件是否以正确的文件结构正确命名。

回答by Demortes

Project -> Clean -> Clean all Projects and then Project -> Build Project worked for me (I did the un-checking generate make-file automatically and then rechecking it before doing this). This was for an AVR (micro-processor programming) project through the AVR CDT plugin in eclipse Juno though.

项目 -> 清理 -> 清理所有项目,然后项目 -> 构建项目对我有用(我没有自动检查生成生成文件,然后在执行此操作之前重新检查它)。这是通过 eclipse Juno 中的 AVR CDT 插件的 AVR(微处理器编程)项目。

回答by sava

I got this same error after renaming and moving around source files. None of the proposed solutions worked for me and I tracked the error to be the meta-files under Debug directory not being updated. Deleting the entire Debug directory and re-build the project solved the problem for me.

重命名和移动源文件后,我遇到了同样的错误。没有一个建议的解决方案对我有用,我跟踪错误是 Debug 目录下的元文件没有更新。删除整个 Debug 目录并重新构建项目为我解决了这个问题。

回答by huseyin tugrul buyukisik

Yet another solution:

另一个解决方案:

I got inside objects.mk file

我进入了 objects.mk 文件

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

USER_OBJS := /home/../mylib.so

LIBS := -lstdc++fs -lGL -lGLU -lGLEW -lglut -lm -lmylib

then didn't read first line. Then altered next line. It was another projects' folder because I copied this using "copy/clone project" feature and this was causing the error for me. I changed myLib.so into /proper_address/reallyMyLib.so and it worked.

然后没读第一行。然后修改下一行。这是另一个项目的文件夹,因为我使用“复制/克隆项目”功能复制了它,这导致了我的错误。我将 myLib.so 更改为 /proper_address/reallyMyLib.so 并且它起作用了。

Warning: It may harm some unknown places! Backup whole project before doing this. Because it says "do not edit".

警告:它可能会伤害一些未知的地方!在执行此操作之前备份整个项目。因为它说“不要编辑”。