无法编译内核模块 [英] Unable to compile the kernel module
本文介绍了无法编译内核模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在ubuntu中构建一个简单的内核,以下是在执行此操作时遇到的错误.
I am trying to build a simple kernel in ubuntu,following are the errors getting while doing this.
make -C /lib/modules/3.13.0-52-generic/build M= modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-52-generic'
make[1]: Makefile: No such file or directory
make[1]: *** No rule to make target `Makefile'. Stop.
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-52-generic'
make: *** [all] Error 2
我的Make文件:
obj-m := module1.o
KERNEL = $(shell uname -r)
all:
make -C /lib/modules/$(KERNEL)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KERNEL)/build M=$(PWD) clean
有人可以帮我吗?
注意:我已经下载了内核源代码
Note: I have already downloaded the kernel source code
推荐答案
使用前,应在Makefile中设置PWD变量.例如
You should set PWD variable in your Makefile before using it. E.g.
PWD = $(shell pwd)
更新:
另外,您的Makefile会混合两种模式的行:KBuild模式(obj-m := module1.o
)和普通的makefile模式(所有其他行).您应该区分模式(使用if
)或对两种模式使用两个不同的文件:
UPDATE:
Also, your Makefile mix lines for two modes: KBuild mode (obj-m := module1.o
) and common makefile mode(all other lines). Your should either distinguish modes(using if
) or use two different files for two modes:
Makefile:
KERNEL = $(shell uname -r)
PWD = $(shell pwd)
all:
make -C /lib/modules/$(KERNEL)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KERNEL)/build M=$(PWD) clean
Kbuild:
obj-m := module1.o
这篇关于无法编译内核模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文