Kernel Module Build Fails: Sys/Types.H: No Such File or Directory

kernel module build fails: sys/types.h: No such file or directory

When you are developing a Linux kernel module, you should forget about the comforts of Standard C library(Glibc).Instead , you will have to use the Kernel C.
So , you should write

#include <linux/types.h>

It will solve the problem.

sys/types.h: No such file or directory

Sorry this was my fault, I made a typo in type and tried to include sys/types.h file, but it was not required at all all types are declared in /usr/src/linux-headers-4.5.0-kali1-common/include/linux/types.h in my case. Thanks everyone.

compilation error fatal error: sys\types.h: No such file or directory #include sys\types.h

You mean
#include <sys/types.h> not #include <sys\types.h>

error compiling: linux/module.h: No such file or directory

First thing you need the kernel sources. Many confuse user space headers and kernel space headers because many of them have the same folder structure. Most of the distros only have the user space headers and not the kernel space ones.

And generally make is used to build a kernel module and not a bare cc. Follow the simple step-by-step explained Hello World kernel module given here



Related Topics



Leave a reply



Submit