gcc 没有拾取内核头文件

gcc 没有拾取内核头文件

我正在尝试编译一个程序,gcc 抛出fatal error: asm/page.h: No such file or directorypage.h 存在。我该如何设置 gcc 来包含路径。我有点疯狂地输入了apt-get install linux-headers*以下结果find / -name page.h

/usr/src/linux-headers-3.18.0-kali3-amd64/include/config/hugetlb/page.h /usr/src/linux-headers-3.18.0-kali3-common/include/asm-generic/page.h /usr/src/linux-headers-3.18.0-kali3-common/include/xen/page.h /usr/src/linux-headers-3.18.0-kali3-common/arch/x86/include/asm/xen/page.h /usr/src/linux-headers-3.18.0-kali3-common/arch/x86/include/asm/page.h /usr/src/linux-headers-3.18.0-kali1-common/include/asm-generic/page.h /usr/src/linux-headers-3.18.0-kali1-common/include/xen/page.h /usr/src/linux-headers-3.18.0-kali1-common/arch/x86/include/asm/xen/page.h /usr/src/linux-headers-3.18.0-kali1-common/arch/x86/include/asm/page.h /usr/src/linux-headers-3.18.0-kali1-amd64/include/config/hugetlb/page.h

答案1

在执行时,您可以使用 -I 参数包含头文件...

gcc myCProgram.c -o myCProgram -I/usr/src/linux-headers-3.18.0-kali1-common/include/asm-generic/

请在此处查看示例

http://www.rapidtables.com/code/linux/gcc/gcc-i.htm

和文档(RTFM)

https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Directory-Options.html

相关内容