次の最小カーネルモジュールをコンパイルしようとしています。
# cat Makefile
obj-m += mymodule.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
これにより、ヘッダーファイルが見つからないというエラーが発生します。だからシンボリックリンクを作成して問題を解決しました。しかし、異なるヘッダーファイルで同じ問題に直面し、2つの異なる場所に対して1つのsimlinkを作成できませんでした。私の理解が間違っているか、この問題をどのように解決しますか?
root@system-yocto:~/kernelModule# make -j
make -C /lib/modules/5.15.54-yocto-standard/build M=/home/root/kernelModule modules
make[1]: Entering directory '/lib/modules/5.15.54-yocto-standard/build'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: arm-poky-linux-gnueabi-gcc (GCC) 11.4.0
You are using: gcc (GCC) 11.4.0
CC [M] /home/root/kernelModule/mymodule.o
In file included from ./include/linux/init.h:5,
from /home/root/kernelModule/mymodule.c:1:
./include/linux/compiler.h:255:10: fatal error: asm/rwonce.h: No such file or directory
255 | #include <asm/rwonce.h>
| ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:288: /home/root/kernelModule/mymodule.o] Error 1
make[1]: *** [Makefile:1886: /home/root/kernelModule] Error 2
make[1]: Leaving directory '/lib/modules/5.15.54-yocto-standard/build'
make: *** [Makefile:4: all] Error 2
root@system-yocto:~/kernelModule# ls -l /lib/modules/5.15.54-yocto-standard/source/include/
total 204
drwxr-xr-x 3 root root 4096 Mar 9 12:34 acpi
drwxr-xr-x 4 root root 4096 Mar 9 12:42 asm-generic
drwxr-xr-x 2 root root 4096 Mar 9 12:34 clocksource
drwxr-xr-x 2 root root 53248 Mar 9 12:34 config
drwxr-xr-x 3 root root 4096 Mar 9 12:34 crypto
drwxr-xr-x 5 root root 4096 Mar 9 12:34 drm
drwxr-xr-x 37 root root 4096 Mar 9 12:34 dt-bindings
drwxr-xr-x 3 root root 4096 Mar 9 12:34 generated
drwxr-xr-x 2 root root 4096 Mar 9 12:34 keys
drwxr-xr-x 2 root root 4096 Mar 9 12:34 kunit
drwxr-xr-x 2 root root 4096 Mar 9 12:34 kvm
drwxr-xr-x 65 root root 40960 Mar 9 12:34 linux
drwxr-xr-x 2 root root 4096 Mar 9 12:34 math-emu
drwxr-xr-x 6 root root 4096 Mar 9 12:34 media
drwxr-xr-x 2 root root 4096 Mar 9 12:34 memory
drwxr-xr-x 2 root root 4096 Mar 9 12:34 misc
drwxr-xr-x 12 root root 4096 Mar 9 12:34 net
drwxr-xr-x 2 root root 4096 Mar 9 12:34 pcmcia
drwxr-xr-x 2 root root 4096 Mar 9 12:34 ras
drwxr-xr-x 2 root root 4096 Mar 9 12:34 rdma
drwxr-xr-x 3 root root 4096 Mar 9 12:34 scsi
drwxr-xr-x 16 root root 4096 Mar 9 12:34 soc
drwxr-xr-x 4 root root 4096 Mar 9 12:34 sound
drwxr-xr-x 3 root root 4096 Mar 9 12:34 target
drwxr-xr-x 3 root root 4096 Mar 9 12:34 trace
drwxr-xr-x 12 root root 4096 Mar 9 12:34 uapi
drwxr-xr-x 2 root root 4096 Mar 9 12:34 vdso
drwxr-xr-x 2 root root 4096 Mar 9 12:34 video
drwxr-xr-x 4 root root 4096 Mar 9 12:34 xen
root@system-yocto:~/kernelModule# ln -s /lib/modules/5.15.54-yocto-standard/source/include/asm-generic/ /lib/modules/5.15.54-yocto-standard/source/include/asm
root@system-yocto:~/kernelModule# make -j
make -C /lib/modules/5.15.54-yocto-standard/build M=/home/root/kernelModule modules
make[1]: Entering directory '/lib/modules/5.15.54-yocto-standard/build'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: arm-poky-linux-gnueabi-gcc (GCC) 11.4.0
You are using: gcc (GCC) 11.4.0
CC [M] /home/root/kernelModule/mymodule.o
In file included from ./include/linux/errno.h:5,
from ./include/linux/string.h:8,
from ./include/linux/bitmap.h:10,
from ./include/linux/cpumask.h:12,
from ./include/linux/mm_types_task.h:14,
from ./include/linux/mm_types.h:5,
from ./include/linux/buildid.h:5,
from ./include/linux/module.h:14,
from /home/root/kernelModule/mymodule.c:2:
./include/uapi/linux/errno.h:1:10: fatal error: asm/errno.h: No such file or directory
1 | #include <asm/errno.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:288: /home/root/kernelModule/mymodule.o] Error 1
make[1]: *** [Makefile:1886: /home/root/kernelModule] Error 2
make[1]: Leaving directory '/lib/modules/5.15.54-yocto-standard/build'
make: *** [Makefile:4: all] Error 2