Your makefile should supply the include directory to use via the -I parameter. I use a
symlink at /usr/src/linux that points to the correct /lib/modules/... directory.
Here's my Makefile:
---------------------------------------------------------------------------------------------------------
# Include directory to point to kernel include
INCLUDE = /usr/src/linux/include
# /usr/src/linux -> /lib/modules/2.6.10-1.741_FC3/build/include
# Compiler
CC = gcc
# Compiler flags.
CFLAGS = -DDEBUG_OUTPUT -D__KERNEL__ -DMODULE -DLINUX -Wall -I$(INCLUDE)
TARGET = pcifinder.o
OBJS = pcifinder.o
all: $(OBJS)
pcifinder.o: pcifinder.cIn file included from /usr/src/linux/include/linux/config.h:4,
from /usr/src/linux/include/linux/fs.h:9,
from pcifinder.c:45:
/usr/include/linux/autoconf.h:1:2: #error Invalid kernel header included in userspace
In file included from /usr/src/linux/include/linux/fs.h:10,
from pcifinder.c:45:
clean:
@rm -f *.o
-------------------------------------------------------------------------------------------------------------
I actually have my own question. Everything appears to be setup correctly but gcc complains
in a few ways. A couple of the relavant error messages (out of many
are:
1. #error Invalid kernel header included in userspace
2. /usr/src/linux/include/linux/linkage.h:5:25: asm/linkage.h: No such file or directory
I am building a kernel module (-D__KERNEL__ -DMODULE) so I don't understand the first message. Also, linkage.h does in fact exist at <asm/linkage.h> so again, this is a mystery. My guess is that gcc is using some other include directory and it is not being initialized correctly to build a kernel module. This exact same Makefile worked fine under kernel 2.4 however. Any ideas?
Steve Q.
ALT Software Inc.