How to include kernel headers in a program

12,150

try this find / -name skbuff.h 2>/dev/null then when it finds the location use the -I/path/to/folder when you compile your program.. If it doesn't find the header you don't have it!

Share:
12,150
adnan kamili
Author by

adnan kamili

Coding is fun :)

Updated on June 04, 2022

Comments

  • adnan kamili
    adnan kamili almost 2 years

    I am writing a libnetfilter_queue program. I am new to linux kernel programming. I need to include linux/skbuff.h, net/checksum.h and many related kernel headers which are not present in /usr/include/linux. I get following error on compilation

     fatal error: linux/skbuff.h: No such file or directory
     fatal error: net/checksum.h: No such file or directory
    
  • shkschneider
    shkschneider over 11 years
    find /usr [...] should be enough ^^
  • adnan kamili
    adnan kamili over 11 years
    I added the path /usr/src/linux-headers-3.2.0-32/include/ but i get following error : /usr/src/linux-headers-3.2.0-32/include/linux/bitops.h:22:24‌​: fatal error: asm/bitops.h: No such file or directory
  • pyCthon
    pyCthon over 11 years
    do you know how to add a directory to your path?
  • adnan kamili
    adnan kamili over 11 years
    g++ -Wall -I /usr/src/linux-headers-3.2.0-32/include/ -o filter -lnetfilter_queue
  • pyCthon
    pyCthon over 11 years
    thats a no, type $PATH in terminal copy paste that then go to your home directory and type vi .bashrc add what your copied and add your desired directory to include it in the search path see if that works for example PATH=$PATH:/usr/src/linux-headers-3.2.0-32/include/:$HOME/bi‌​n