简体   繁体   English

内核模块导致文件错误

[英]Kernel Module make file errors

So I am trying to build a simple first kernel module in arch linux but I am getting an error with my make file 所以我试图在arch linux中构建一个简单的第一个内核模块,但是我的make文件出错了

I tried find the kernel headers for my uname -r but no luck 我尝试找到我的uname -r的内核头文件,但没有运气

obj-m += Test.c
KIDR = /usr/lib/modules/5.1.3-arch1-1-ARCH
all:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
        echo DONE

my errors are: 我的错误是:

prompt$ make
make -C  SUBDIRS=/home/johndoe/KernelModule modules
make[1]: *** SUBDIRS=/home/johndoe/KernelModule: No such file or directory.  Stop.
make: *** [Makefile:4: all] Error 2

and my code is: 我的代码是:

#include <linux/init.h>
#include <linux/module.h>
static int entry_func(void){
        printk("ENTERED");
        return 0;
}

static exit_func(void){
        printk("EXITING");
}
module_init(entry_func);
module_exit(exit_func);

It seems that your path isn´t correct. 看来你的道路不正确。 Please check the path of your source file. 请检查源文件的路径。 You use the $SUBDIRS variable for the path where your external module is located. 您可以将$SUBDIRS变量用于外部模块所在的路径。 So you can remove this if your module is located by your source file. 因此,如果您的模块位于源文件中,则可以删除此项。

obj-m   += Test.o

all:
    make -C ${KDIR} modules

clean:
    make -C ${KDIR} clean

You can find additional information here . 您可以在此处找到更多信息。

Do you have installed the kernel sources? 你安装了内核源码吗? Otherwise, your system doesn´t contain any sources. 否则,您的系统不包含任何来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM