I am trying to compile module. I can do so by calling make, which calls
make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
But I want to see preprocessed output, So I am trying to compile manually with cc -E file.c
. The problem is, It cannot see header <linux/init.h>
:
fatal error: linux/init.h: No such file or directory #include <linux/init.h>
I have notice, when make is called, it first enter this dir /usr/src/linux-headers-5.0.0-38-generic
, There is probably the header, but I do not know where. I have tried gcc -E -I'/usr/src/linux-headers-5.0.0-38-generic file.c
, but still the same error. So how is possible to include kernel headers (which <linux/init.h> is
) in user mode - that is how to include headers from another dir?
PS: as @uzsolt in comments suggested, I add include
to the end of path: gcc -I /usr/src/linux-headers-5.0.0-38-generic/include
. But then another header is missing - <asm/linkage.h>
, and again - I have no clue in what dir this header is.