0

i have a problem on my kali linux - i wanted to write a simple program which included 3 header files:

#include <linux/input.h>
#include <stdio.h>
#include <fcntl.h>

i tried to compile it with gcc (default compilation settings) and then i got a whole bunch of errors one after another, e.g.

/usr/include/linux/cache.h:5:10: fatal error: uapi/linux/kernel.h: No such file or directory
5 | #include <uapi/linux/kernel.h>
  |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

then i tried to locate the uapi/linux/ directory and copy it to /usr/include so compiler can find it, but then

/usr/include/linux/cache.h:5:10: fatal error: uapi/linux/kernel.h: No such file or directory
5 | #include <uapi/linux/kernel.h>
  |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

after several tries of copying directories to /usr/include i finally get error that says type names of "u32", "u16" are unknown (they are for sure defined in some headers). i don't want to mess with my header files on my own because it doesn't work, so what should i do to compile theese headers?

3
  • 4
    Since when does a "simple program" have to include Linux kernel headers?
    – Kusalananda
    Feb 21 '21 at 10:48
  • 2
    You should never be copying anything without a good reason to do so to any subfolder of /usr that isn't under /usr/local - /usr is for system-installed stuff. Feb 21 '21 at 10:55
  • You may just need to add -I/usr/src/linux-headers-5.10.0-3-common/include but replace 5.10.0-3 with your kernel version.
    – Stewart
    Feb 21 '21 at 20:59
3

You may have not installed the required linux-headers package, and it should be of the same version as your kernel.

Do note that Kali Linux is based on Debian Testing, while some parts also do come from Unstable or even Experimental, which means you may hit bugs and stability issues.

1
  • i actually did install theese, i forgot to write that down - if you're right with that second part of your answer, i think i must change kali to other linux-based os ://
    – pazdinho_
    Feb 21 '21 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.