Question

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.

Was it helpful?

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

OTHER TIPS

The file include/linux/config.h has been removed from 2.6.19 kernel. So remember this if you build your favorite module against the new 2.6.19 kernel and you get an error similar to this:

fatal error: linux/config.h: No such file or directory
 #include <linux/config.h>

src:

http://www.linuxquestions.org/questions/linux-kernel-70/removal-of-include-linux-config-h-file-in-2-6-19-kernel-506363/

You may try just touching the linux/config.h file and try make.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top