【发布时间】:2018-02-15 16:33:40
【问题描述】:
我正在开发一个网络过滤器并在虚拟机上编译它。
matt@ubuntu:~$ make
gcc -c -O2 -W -isystem /lib/modules/4.4.0-87-generic/build/include -D__KERNEL__ -DMODULE test10.c -I.
In file included from /usr/src/linux-headers-4.4.0-87/include/linux/kernel.h:6:0,
from structs1.h:2,
from test10.c:1:
/usr/src/linux-headers-4.4.0-87/include/linux/linkage.h:7:25: fatal error: asm/linkage.h: No such file or directory
compilation terminated.
makefile:2: recipe for target 'test' failed
make: *** [test] Error 1
以上是我用于尝试构建我的内核模块的 GCC 命令以及它引发的后续错误。
在研究这个问题时,我发现了一种可能的解决方案,涉及指定内核版本:
KERNEL_VER=/usr/src/linux-headers-4.4.0-87/arch/x86/
但是有两个问题:
除了创建符号链接之外,我不确定如何在我的 make 文件中实际使用它,如下所示,以及
我查看了这个文件夹 (
/usr/src/linux-headers-4.4.0-87/arch/x86/) 和子文件夹,它没有任何相同的kernel.h文件——这正是我所需要的。
生成文件:
test:
gcc -c -O2 -W -isystem /lib/modules/4.4.0-87-generic/build/include -D__KERNEL__ -DMODULE test10.c -I.
对此的任何帮助将不胜感激。
【问题讨论】:
标签: c linux-kernel network-programming netfilter