打算在ubuntu16上编译linux3.4.66内核,但是遇到
In file included from include/linux/compiler.h:48:0,
from include/linux/stddef.h:4,
from include/linux/posix_types.h:4,
from include/linux/types.h:17,
from include/linux/page-flags.h:8,
from kernel/bounds.c:9:
include/linux/compiler-gcc.h:100:30: fatal error: linux/compiler-gcc5.h: No such file or directory
第一反应是gcc版本过高.于是开始gcc降级之路
先安装gcc4.8
apt-get install gcc-4.8
把4.8加入候选
update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100 (并且优先级为100)
然后查看gcc版本 gcc -v
后面的g++大家也可以按上面方法更换
后来真正解决问题的是添加了缺失的头文件
解决方法:https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/include/linux/compiler-gcc5.h?id=2c07053b8e1e0c22bb54dfbdf8e86a70f8bf00fc
复制内容保存为compiler-gcc5.h,放在要编译内核模块的内核代码的include/linux下