Results 1 to 2 of 2
Thread: Hello Kernel Compiling Error
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Sep 2007
Hello Kernel Compiling Error
I've been trying to implement the hello world code from the device
drivers chapter of "Beginning Linux Programming". I'm trying to create
module that I can test with the insmod command. I keep getting errors
because I'm compiling using the wrong header:
In file included from /usr/include/linux/module.h:10,
/usr/include/linux/config.h:5:2: #error Incorrectly using glibc headers
for a kernel module
However, I've invoked the compiler as follows:
gcc -D__KERNEL__ -DMODULE -DMODVERSIONS -O2 -Wall -I /usr/src/linux/include -o samplerw.o -c samplerw.c
But, despite my providing what I think should be a directory in which to
search for *.h files (which I believe are the correct ones for my
system, a Fedora Core 3 install) for kernel compilations, I keep getting
the error above based on gcc including the wrong header file
My system details are as below.
# uname -a
Linux wiprosdm 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux
If some body could help that would be appreciable.
Thanks in advance.
- Join Date
- Aug 2006
Try this makefile, save it in the directory you're working (before the make commands you must have real tabs, not spaces):
obj-m += samplerw.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