0

我刚开始从事内核模块编程,我很难让 makefile 正确编译 c 文件。我正在使用 Manjaro 5.4

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

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/cpupower 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 information 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

我很困惑,我无法找出它给我这个错误的原因。

4

0 回答 0