You are not logged in.
Hello everyone, i encountered a wide-spread problem with linux headers. I've already read all topics about that problem, but nothing helped.
Version of my kernel: 6.13.6-zen1-1-zen
I try to compile a simple hello-world module and gcc doesn't see init.h, but it sees linux/module.h and linux/kernel.h, because it looks default directory /usr/include/ and there is no this header.
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void) {
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel world\n"); }
module_init(hello_init);
module_exit(hello_exit);
Moreover, i dont have directory /usr/src/linux-headers$(uname -r) , package linux-*-headers doesnt provide it:
# pacman -Ql linux-headers | grep /usr/src
>>>> linux-headers /usr/src/
>>>> linux-headers /usr/src/linux
# pacman -Ql linux-headers | grep linux/init.h
>>>> linux-headers /usr/lib/modules/6.13.6-arch1-1/build/include/linux/init.h
# pacman -Ql linux-headers | grep linux/kernel.h
>>>> linux-headers /usr/lib/modules/6.13.6-arch1-1/build/include/linux/kernel.h
>>>> linux-headers /usr/lib/modules/6.13.6-arch1-1/build/include/uapi/linux/kernel.h
And all the same for linux-zen-headers, but "zen" instead of "arch"
I tried to put these paths like
gcc -I/usr/lib/modules/6.13.6-zen1-1-zen/build/include/ hello_world.c
, but compiler responded:
/usr/lib/modules/6.13.6-zen1-1-zen/build/include/linux/compiler.h:316:10: fatal error: asm/rwonce.h: No such file or directory
316 | #include <asm/rwonce.h>
| ^~~~~~~~~~~~~~
However this header exists in ./generated, a added this include path to, but same error.
I reinstalled packages: linux, linux-zen, linux-headers, linux-zen-headers, kernel-devel; rebooted my system, but unsuccessfully.
Last edited by mr_creeper (2025-03-11 23:58:23)
Offline
I forgot to mention that I have directories "/usr/src/linux/include" and "/usr/src/linux-zen/include/" . And there are these headers too, but attempts to compile with these include paths finished with same error.
Offline
that's my zfs test vm
[main@zfstest ~]$ pacman -Qs linux
local/archlinux-keyring 20250123-1
Arch Linux PGP keyring
local/base 3-2
Minimal package set to define a basic Arch Linux installation
local/base-devel 1-2
Basic tools to build Arch Linux packages
local/dbus-broker 36-4
Linux D-Bus Message Broker
local/dbus-broker-units 36-4
Linux D-Bus Message Broker - Service units
local/efibootmgr 18-3
Linux user-space application to modify the EFI Boot Manager
local/filesystem 2024.11.21-1
Base Arch Linux files
local/iptables 1:1.8.10-2
Linux kernel packet control tool (using legacy interface)
local/keyutils 1.6.3-3
Linux Key Management Utilities
local/kmod 34.1-1
Linux kernel module management tools and library
local/libcap-ng 0.8.5-3
A library for Linux that makes using posix capabilities easy
local/linux 6.13.6.arch1-1
The Linux kernel and modules
local/linux-api-headers 6.13-1
Kernel headers sanitized for use in userspace
local/linux-firmware 20250210.5bc5868b-1
Firmware files for Linux
local/linux-firmware-whence 20250210.5bc5868b-1
Firmware files for Linux - contains the WHENCE license file which documents the vendor license details
local/linux-hardened 6.13.6.hardened1-1
The Security-Hardened Linux kernel and modules
local/linux-hardened-headers 6.13.6.hardened1-1
Headers and scripts for building modules for the Security-Hardened Linux kernel
local/linux-headers 6.13.6.arch1-1
Headers and scripts for building modules for the Linux kernel
local/linux-lts 6.12.18-1
The LTS Linux kernel and modules
local/linux-lts-headers 6.12.18-1
Headers and scripts for building modules for the LTS Linux kernel
local/linux-xanmod 6.13.6-1
The Linux kernel and modules with Xanmod patches
local/linux-xanmod-headers 6.13.6-1
Headers and scripts for building modules for the Linux Xanmod - Stable Mainline [MAIN] kernel
local/linux-zen 6.13.6.zen1-1
The Linux ZEN kernel and modules
local/linux-zen-headers 6.13.6.zen1-1
Headers and scripts for building modules for the Linux ZEN kernel
local/man-pages 6.13-1
Linux man pages
local/pacman-mirrorlist 20250101-1
Arch Linux mirror list for use by pacman
local/util-linux 2.40.4-1
Miscellaneous system utilities for Linux
local/util-linux-libs 2.40.4-1
util-linux runtime libraries
[main@zfstest ~]$ ls -alFh /usr/src
insgesamt 8,0K
drwxr-xr-x 2 root root 4,0K 11. Mär 20:50 ./
drwxr-xr-x 9 root root 4,0K 11. Mär 20:50 ../
lrwxrwxrwx 1 root root 35 7. Mär 21:19 linux -> ../lib/modules/6.13.6-arch1-1/build/
lrwxrwxrwx 1 root root 48 8. Mär 23:45 linux-hardened -> ../lib/modules/6.13.6-hardened1-1-hardened/build/
lrwxrwxrwx 1 root root 34 7. Mär 19:50 linux-lts -> ../lib/modules/6.12.18-1-lts/build/
lrwxrwxrwx 1 root root 43 8. Mär 14:22 linux-xanmod -> ../lib/modules/6.13.6-x64v3-xanmod1-1/build/
lrwxrwxrwx 1 root root 38 7. Mär 21:18 linux-zen -> ../lib/modules/6.13.6-zen1-1-zen/build/
[main@zfstest ~]$ find /usr/lib/modules -name init.h
/usr/lib/modules/6.13.6-arch1-1/build/include/linux/init.h
/usr/lib/modules/6.13.6-arch1-1/build/include/linux/sched/init.h
/usr/lib/modules/6.13.6-arch1-1/build/include/trace/stages/init.h
/usr/lib/modules/6.13.6-arch1-1/build/arch/x86/include/asm/init.h
/usr/lib/modules/6.13.6-zen1-1-zen/build/include/linux/init.h
/usr/lib/modules/6.13.6-zen1-1-zen/build/include/linux/sched/init.h
/usr/lib/modules/6.13.6-zen1-1-zen/build/include/trace/stages/init.h
/usr/lib/modules/6.13.6-zen1-1-zen/build/arch/x86/include/asm/init.h
/usr/lib/modules/6.13.6-hardened1-1-hardened/build/include/linux/init.h
/usr/lib/modules/6.13.6-hardened1-1-hardened/build/include/linux/sched/init.h
/usr/lib/modules/6.13.6-hardened1-1-hardened/build/include/trace/stages/init.h
/usr/lib/modules/6.13.6-hardened1-1-hardened/build/arch/x86/include/asm/init.h
/usr/lib/modules/6.13.6-x64v3-xanmod1-1/build/include/linux/init.h
/usr/lib/modules/6.13.6-x64v3-xanmod1-1/build/include/linux/sched/init.h
/usr/lib/modules/6.13.6-x64v3-xanmod1-1/build/include/trace/stages/init.h
/usr/lib/modules/6.13.6-x64v3-xanmod1-1/build/arch/x86/include/asm/init.h
/usr/lib/modules/6.12.18-1-lts/build/include/linux/init.h
/usr/lib/modules/6.12.18-1-lts/build/include/linux/sched/init.h
/usr/lib/modules/6.12.18-1-lts/build/include/trace/stages/init.h
/usr/lib/modules/6.12.18-1-lts/build/arch/x86/include/asm/init.h
[main@zfstest ~]$
so following the symlinks all init.h are in place
also: have you https://wiki.archlinux.org/title/Compile_kernel_module given a look?
Offline
Why are you not following modules?
Offline
thank you guys, I just had to read guide more attentively. The path i needed was /lib/modules/6.13.6-zen1-1-zen/build, and makefile should be written something like this:
ifneq ($(KERNELRELEASE),)
obj-m := hello_world.o
else
KERN_DIR ?= /lib/modules/$(uname - r)/build
default:
$(MAKE) -C $(KERN_DIR) M=$(PWD) modules
endif
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions
Last edited by mr_creeper (2025-03-12 07:09:00)
Offline
Your system's shell does not set the standard environment variable PWD? You intend to never update from 6.13.6-zen1-1? You are aware the kernel build system provides its own clean rule? Why specify the modules target which is the default?
Last edited by loqs (2025-03-12 00:04:57)
Offline