Results 1 to 10 of 10

Thread: Header file problem ..

  1. #1
    Join Date
    Apr 2011
    Location
    Chittagong,Bangladesh
    Beans
    149
    Distro
    Ubuntu 14.04 Trusty Tahr

    Header file problem ..

    I m new in C , I found this error during compilation
    Code:
    trendchip.c:19:24: fatal error: linux/slab.h: No such file or directory
    ..... How can I solve this ?where i find this header file ?

  2. #2
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: Header file problem ..

    Install the linux-headers package that corresponds to your kernel version.
    「明後日の夕方には帰ってるからね。」


  3. #3
    Join Date
    Apr 2011
    Location
    Chittagong,Bangladesh
    Beans
    149
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Header file problem ..

    Quote Originally Posted by Bachstelze View Post
    Install the linux-headers package that corresponds to your kernel version.
    I already did this..but same problem again

  4. #4
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: Header file problem ..

    Then you will need to provide additional information (and really, you should have done that in your first post!). Where does the code come from? How are you compiling it?
    「明後日の夕方には帰ってるからね。」


  5. #5
    Join Date
    Apr 2011
    Location
    Chittagong,Bangladesh
    Beans
    149
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Header file problem ..

    Here is the code http://pastebin.com/2ELRTqsV

    i m using gcc 4.7

  6. #6
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: Header file problem ..

    By "how you are compiling it" I meant "which command are you running",of course...
    「明後日の夕方には帰ってるからね。」


  7. #7
    Join Date
    Apr 2011
    Location
    Chittagong,Bangladesh
    Beans
    149
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Header file problem ..

    Quote Originally Posted by Bachstelze View Post
    By "how you are compiling it" I meant "which command are you running",of course...
    Code:
    gcc -o trendchip trendchip.c

  8. #8
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: Header file problem ..

    That's not how you compile kernel code, but you will have to Google how to do it or wait for someone else to answer because I am not a kernel expert myself.
    「明後日の夕方には帰ってるからね。」


  9. #9
    Join Date
    Nov 2005
    Location
    Sendai, Japan
    Beans
    11,296
    Distro
    Kubuntu

    Re: Header file problem ..

    Or alternatively, look in the documentation. You probably did not obtain this code by itself.
    「明後日の夕方には帰ってるからね。」


  10. #10
    Join Date
    Jun 2010
    Beans
    92

    Re: Header file problem ..

    Try something like this, replacing the linux version with the one you have:

    gcc -Wall -D__KERNEL__ -DMODULE -I/usr/src/linux-2.6.28-11-generic/include -O -g -I.. -c -o trendchip.o trendchip.c


    Also, here is a generic Makefile.
    Put Makefile in the source's directory and enter

    make

    Code:
    # obj-m is a list of what kernel modules to build.  The .o and other
    # objects will be automatically built from the corresponding .c file -
    # no need to list the source files explicitly.
    
    obj-m := trendchip.o 
    
    # KDIR is the location of the kernel source.  The current standard is
    # to link to the associated source tree from the directory containing
    # the compiled modules.
    KDIR  := /lib/modules/$(shell uname -r)/build
    
    # PWD is the current working directory and the location of our module
    # source files.
    PWD   := $(shell pwd)
    
    # default is the default make target.  The rule here says to run make
    # with a working directory of the directory containing the kernel
    # source and compile only the modules in the PWD (local) directory.
    default:
    	$(MAKE) -C $(KDIR) M=$(PWD) modules
    
    clean:
    	${MAKE} -C ${KDIR} M=${PWD} clean
    Last edited by xb12x; February 10th, 2013 at 10:19 PM.

Bookmarks

Posting Permissions

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