【问题标题】:Make going into extra directory进入额外目录
【发布时间】:2018-01-10 19:54:19
【问题描述】:

我正在尝试制作一个简单的 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("Daniel");
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 loaded.
}

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

module_init(hello_init);
module_exit(hello_cleanup);

这是生成文件:

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

我把它们放在 ~/HelloModule 当我在那里运行 make 命令时,它给了我这个错误:

make -C /lib/modules/4.13.0-25-generic/build M=/home/dan/HelloModule modules
make[1]: Entering directory '/usr/src/linux-headers-4.13.0-25-generic'
scripts/Makefile.build:44: /home/dan/HelloModule/Makefile: No such file or directory
make[2]: *** No rule to make target '/home/dan/HelloModule/Makefile'.  Stop.
Makefile:1550: recipe for target '_module_/home/dan/HelloModule' failed
make[1]: *** [_module_/home/dan/HelloModule] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.13.0-25-generic'
makefile:4: recipe for target 'all' failed
make: *** [all] Error 2

出于某种原因,在第 4 行,make 脚本似乎正试图进入目录 /home/dan/HelloModule/Makefile,这不是目录。关于为什么会发生这种情况以及如何解决它的任何想法?

【问题讨论】:

    标签: makefile compiler-errors linux-device-driver kernel-module


    【解决方案1】:

    我想通了。它没有尝试访问目录它尝试访问区分大小写的 Makefile,因此它必须是 Makefile 而不是 makefile

    【讨论】:

    • 提示:所有标准 Linux 文件系统都区分大小写。如果使用基于 Linux 的发行版,您应该养成将字符“a”和“A”视为与字符“x”和“8”一样独特的习惯:看到错误的情况需要发出警报,就像大为错误的字符。大多数其他基于 UNIX 的系统也是如此,例如 BSD、Solaris 等。MacOS 是这里的例外。
    猜你喜欢
    • 2011-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-04
    • 2011-08-29
    • 2012-05-30
    相关资源
    最近更新 更多