Issue
I have written a test module for linux kernel. This module needs headers <linux/config.h>
and <asm/system.h>
. When I issued make
, it gave me error
fatal error: linux/config.h: No such file or directory
and in the same way if I comment config.h
header then it says asm/system.h: No such file or directory
. I tried searching for the problem and came across solution that these headers belong ti kernel-headers
package. I installed this package (although it was already installed on my system). But then to it cannot find these two headers. I found solution of soft-linking autoconf.h
from /usr/src/
path, but unfortunately I could not find any headers folder installed on this path. Can anyone tell me where is the problem with my code? I am using F20 operating system and kernel version is 3.12.9-301.fc20.x86_64.
Solution
It seems that your Makefile don't know where to search for kernel headers. Can you try with this Makefile : just type make
and it should build using kernel-headers of your current running kernel.
# Run this Makefile as follows:
# (MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
#
KDIR= /lib/modules/$(shell uname -r)/build
obj-m := test.o
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
install:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules_install
depmod -a
clean:
rm -f *~
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
Answered By - Mali