Hello Kernel Compiling Error

Claudio Bley bley@mail.cs.uni-magdeburg.de
Sun Feb 6 12:10:00 GMT 2005


On Thu, Feb 03, 2005 at 09:39:06AM -0700, Darren OConnor wrote:
> Hello,
> 
> I've been trying to implement the hello world code from the device
> drivers chapter of "Beginning Linux Programming".  I'm trying to create
> a 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,
>                  from hellokernel.c:3:
> /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__ -isystem/lib/modules/2.6.9-1.667/build/include/linux -
> DMODULE -Wall -O2   -c -o hellokernel.o hellokernel.c
> 
> And I tried:
> 
> gcc -D__KERNEL__ -I/lib/modules/2.6.9-1.667/build/include/linux -
> DMODULE-Wall -O2   -c -o hellokernel.o hellokernel.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.
> 
> Thanks in advance for any help!
> -D


Hi, 

just try to remove the last part of your include directory, i.e. 

-I/lib/modules/2.6.9-1.667/build/include

Usually, you include linux kernel headers like

#include <linux/module.h>

which already contains the "linux" part. 

HTH
Claudio 
> 



More information about the Gcc-help mailing list