【问题标题】:Why is make printing "make: Nothing to be done for `all'."? [duplicate]为什么要打印“make:Nothing to be done for `all'.”? [复制]
【发布时间】:2015-10-02 08:19:17
【问题描述】:

这是一个“Hello.c”模块和“Makefile”。从 woking 目录执行 make 后,我收到以下消息:

make: `all' 无事可做。

这是“Hello.c”文件:

#include <linux/module.h>    // included for all kernel modules
#include <linux/kernel.h>    // included for KERN_INFO
#include <linux/init.h>      // included for __init and __exit macros

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lakshmanan");
MODULE_DESCRIPTION("A Simple Hello World module");

static int __init hello_init(void) {
  printk(KERN_INFO "Hello world!\n");
  return 0;    // Non-zero return means that the module couldn't be
}

static void __exit hello_cleanup(void) {
    printk(KERN_INFO "Cleaning up module.\n");
}   

module_init(hello_init); 
module_exit(hello_cleanup);

还有“Makefile”:

obj-m += hello.o

all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

我尝试了所有建议,并在终端中得到了这个:

root@stupid-HP:/home/stupid/cpz/module$ pwd
/home/stupid/cpz/module
root@stupid-HP:/home/stupid/cpz/module$ ls
hello.c  Makefile
root@stupid-HP:/home/stupid/cpz/module$ make
make: Nothing to be done for `all'.
root@stupid-HP:/home/stupid/cpz/module$ make clean
make: Nothing to be done for `clean'.
root@stupid-HP:/home/stupid/cpz/module$ make clean all
make: Nothing to be done for `clean'.
make: Nothing to be done for `all'.
root@stupid-HP:/home/stupid/cpz/module$ ls
hello.c  Makefile
root@stupid-HP:/home/stupid/cpz/module$ make
make: Nothing to be done for `all'.
root@stupid-HP:/home/stupid/cpz/module$ vi hello.c  # modified again
root@stupid-HP:/home/stupid/cpz/module$ make clean
make: Nothing to be done for `clean'.
root@stupid-HP:/home/stupid/cpz/module$ make
make: Nothing to be done for `all'.

【问题讨论】:

  • 我检查了,当前工作目录中没有其他 makefile。只有两个文件 hello.c 和 makefile。 (谢谢回复)
  • 如果你的程序被编译,编译器不会被调用。您必须修改源文件或删除编译器输出才能立即运行编译器。这是基于时间戳的。
  • 这可能只是意味着hello.o 是最新的。您可以运行make clean all 并查看是否再次收到该消息。
  • 确保make -C ... 用TAB(不是空格)缩进
  • @sergej 谢谢......正如你所说,我删除了 Makefile 中的空格并用 TAB 替换。现在它的工作和我能够使用 insmod 。

标签: c makefile linux-kernel linux-device-driver gnu-make


【解决方案1】:
  1. make clean 然后make 再次
  2. 根据 make 文件格式检查空格和制表符
  3. 验证内核库的路径

【讨论】:

  • 上帝,干净为我做的!为什么我必须打扫?
  • @Curnelious clean 是您删除任何先前构建的内容,以确保您获得干净的构建并且没有来自先前构建的任何旧文件。
【解决方案2】:

根据时间戳制作作品。如果您更改某些源文件,请编译它们并相应地构建图像。如果您不更改源文件,则编译器与您的项目无关。 make 不像gcc 那样每次都编译是否需要新版本。这是为您的项目使用 make 的众多优势之一。

【讨论】:

  • 如何强制编译编译?忽略更改检查
  • 我不知道这种方法,但你可以使用触摸更改时间戳或清理然后重新制作
【解决方案3】:

您应该删除 Makefile 中的空间。在makefile中,只能使用tab。

我再次测试了您的代码,它可以与标签一起使用

【讨论】:

    【解决方案4】:

    编译器只是告诉您您的代码已经编译并且您的代码没有任何更改(它是最新的),然后它不会编译。是编译器的内置功能,如果源代码文件没有变化,编译器不会浪费时间。

    make 之前使用make clean 或修改Hello.c 并构建您的项目。

    【讨论】:

    • 我输入了两个 cmd ,我编辑了问题,所以你可以检查响应。我正在使用 Ubuntu 14.04。我在当前工作目录中编写了 hello.c 和 makefile,我正在尝试将此模块添加到内核中。我错过了什么步骤吗?
    • make clean 清理所有非文件夹文件,不适用于我的Ubuntu 20.04LTS
    • 这取决于你的makefile。它是否定义了一个干净的规则?
    【解决方案5】:

    尝试:make clean 删除可执行文件(./a.out)并再次尝试编译! 您可能在某些功能中发生了一些变化,并且看不到它

    【讨论】:

      【解决方案6】:

      以防万一有人遇到和我一样的问题:

      当您的文件夹之一与可执行文件同名时,Eclipse 无法正确构建。如果是这种情况,无论您做什么,您总是会收到“无事可做”的消息。解决方案是重命名文件夹或可执行文件。详情可见here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-11-04
        • 2016-01-14
        • 2018-04-04
        • 2021-12-15
        • 2023-01-11
        • 2016-03-20
        相关资源
        最近更新 更多