Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I just began reading a Linux device driver tutorial: Writing device drivers in Linux: A brief tutorial But I can't find the required init.h and module.h and some other ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    21

    Can't find <linux/init.h> and <linux/module.h>

    Hi, I just began reading a Linux device driver tutorial:
    Writing device drivers in Linux: A brief tutorial
    But I can't find the required init.h and module.h and some other header files. Should they lie in the /usr/include/linux directory? Or, if they are not installed in my system, what should I do?

  2. #2
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    You need to install the kernel-source (or kernel-devel) package.

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    21
    I just installed the kernel-devel package, but still I can't find these header files.

  4. #4
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    It could be that you also need to have the kernel-headers installed. On my openSUSE 10.3 system, the headers you mentioned are provided by kernel-source.

  5. #5
    Just Joined!
    Join Date
    Feb 2008
    Posts
    50
    You must use the kernel headers of the kernel you are compiling against. Using the default /usr/include/linux won't work.

    Makefile should like this;
    ----------------------------------------------------------------
    TARGET := hello-1
    WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
    INCLUDE := -isystem /lib/modules/`uname -r`/build/include
    CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
    CC := gcc-3.0

    ${TARGET}.o: ${TARGET}.c

    .PHONY: clean

    clean:
    rm -rf {TARGET}.o
    ----------------------------------------------------------------

    Pankaj.

  6. #6
    Just Joined!
    Join Date
    Feb 2008
    Posts
    21
    Thanks!
    Besides, I have found that these header files are in the kernel directory instead of the standard include directory.

Posting Permissions

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