다음과 같은 최소 커널 모듈을 컴파일하려고 합니다.
# 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