【问题标题】:Unable to compile the kernel module无法编译内核模块
【发布时间】:2015-07-31 08:48:21
【问题描述】:

我正在尝试在 ubuntu 中构建一个简单的内核,以下是执行此操作时遇到的错误。

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

谁能帮帮我。

注意:我已经下载了内核源代码

【问题讨论】:

  • HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf scripts/kconfig/conf --silentoldconfig Kconfig make[1]: 离开目录/usr/src/linux-headers-3.13.0-53-generic' make[1]: Entering directory /usr/src/linux- headers-3.13.0-53-generic' make[2]: *** 没有规则来制作目标 /usr/src/linux-headers-3.13.0-53-generic/arch/x86/syscalls/syscall_32.tbl', needed by arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h'。停止。 make[1]: *** [archheaders] 错误 2 make[1]: 离开目录 `/usr/src/linux-headers-3.13.0-53-generic' make: *** [all] Error 2跨度>
  • 您好,我已经按照您的说法更新了 make 文件,并且出现了错误

标签: kernel


【解决方案1】:

您应该在使用前在 Makefile 中设置 PWD 变量。例如

PWD = $(shell pwd)

更新: 此外,您的 Makefile 混合行有两种模式:KBuild 模式 (obj-m := module1.o) 和通用 makefile 模式(所有其他行)。您应该区分模式(使用if)或为两种模式使用两个不同的文件:

生成文件:

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

【讨论】:

  • 是的,我这样做了,但仍然出现问题。如何解决这个问题,请帮助我。
猜你喜欢
  • 1970-01-01
  • 2012-12-10
  • 2011-05-03
  • 1970-01-01
  • 2020-03-27
  • 2011-03-28
  • 2011-06-06
相关资源
最近更新 更多