Ubuntu 上的 Linux 内核驱动程序构建错误“没有规则来创建目标 arch/x86/entry/syscalls/syscall_32.tbl”

问题描述 投票:0回答:1

未构建简单的 Linux 内核驱动程序

环境:

  • 操作系统:Ubuntu 24LTS
  • Linux 内核:6.8.0-47-generic
  • C++17 GCC 编译器

ldd.cpp

#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Debanjan Tewary");
MODULE_DESCRIPTION("A simple Hello, World Module");

static int hello_init(void)
{
    printk(KERN_INFO "Hello, world!\n");
    return 0;
}

static void hello_exit(void)
{
    printk(KERN_INFO "Goodbye, world!\n");
}

module_init(hello_init);
module_exit(hello_exit);

这是

Makefile

obj-m += ldd.o

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

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

运行

make
命令时出错:

make -C /lib/modules/6.8.0-47-generic/build M= modules
make[1]: Entering directory '/usr/src/linux-headers-6.8.0-47-generic'
make[3]: *** No rule to make target 'arch/x86/entry/syscalls/syscall_32.tbl', needed by 'arch/x86/include/generated/uapi/asm/unistd_32.h'.  Stop.
make[2]: *** [arch/x86/Makefile:249: archheaders] Error 2
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.8.0-47-generic'
make: *** [Makefile:4: all] Error 2

我使用的是 Ubuntu,需要 arch/x86 吗?我在 Google 上找不到任何可用的解决方案。

ubuntu linux-kernel linux-device-driver kernel-module
1个回答
0
投票

只是一个愚蠢的事情解决了它。我必须删除文件夹名称中的空格。

修复:

/Linux Driver Test
->
/Linux_Driver_Test

© www.soinside.com 2019 - 2024. All rights reserved.