内核模块Makefile为什么不能识别目录中的任何文件?

问题描述

我刚刚开始从事内核模块编程的工作,而我很难使makefile正确编译c文件。我正在使用manjaro 5.4

当我在与代码和此Makefile相同的目录中执行make时:

obj-m += hello1.o

PATH = /usr/lib/modules/$(shell uname -r)/build

all:
    $(MAKE) -C $(PATH) M=$(PWD) modules

clean:
    $(MAKE) -C $(PATH) M=$(PWD) clean

我得到了

输出
make -C /usr/lib/modules/5.4.67-1-manjaro/build M=/home/aidan/Documents/kernelProgramming/hw2 modules
make: make: No such file or directory
make: *** [Makefile:7: all] Error 127

我已检查是否已安装所有正确的标题

pacman -Qs "^linux"
local/@R_502_6273@power 5.7-1 (linux-tools)
    Linux kernel tool to examine and tune power saving related features of your processor
local/efibootmgr 17-2
    Linux user-space application to modify the EFI Boot Manager
local/flatpak 1.8.1-1
    Linux application sandBoxing and distribution framework (formerly xdg-app)
local/iptables 1:1.8.5-2
    Linux kernel packet control tool (using legacy interface)
local/keyutils 1.6.3-1
    Linux Key Management Utilities
local/kmod 27-2
    Linux kernel module management tools and library
local/ladspa 1.15-2
    Linux Audio Developer's Simple Plugin API (LADSPA)
local/lib32-keyutils 1.6.3-1
    Linux Key Management Utilities (32-bit)
local/liburing 0.7-2
    Linux-native io_uring I/O access library
local/linux-api-headers 5.8-1
    Kernel headers sanitized for use in userspace
local/linux-firmware 20200923.r1716.afbfb5f-1
    Firmware files for Linux (manjaro Overlay Package)
local/linux-lts-headers 1:5.4-3
    Header files and scripts for building modules for the latest LTS kernel (Metapackage)
local/linux54 5.4.67-1
    The Linux54 kernel and modules
local/linux54-headers 5.4.67-1
    Header files and scripts for building modules for Linux54 kernel
local/lirc 1:0.10.1-6
    Linux Infrared Remote Control utilities
local/man-pages 5.08-1
    Linux man pages
local/python-distro 1.5.0-1
    Linux OS platform @R_882_4045@ion API
local/tlp 1.3.1-2
    Linux Advanced Power Management

路径/usr/lib/modules/5.4.67-1-manjaro/build如下所示:

$ ls
arch   crypto   include  kernel    mm              samples   sound  virt
block  drivers  init     lib       Module.symvers  scripts   tools
certs  fs       Kconfig  Makefile  net             security  usr

我很沮丧,我找不到导致该错误的原因。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)