Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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,
    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__ -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.

    - Mani

  2. #2
    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
    	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
    	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    To compile type "make", to cleanup the files type "make clean".


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts