打算在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++大家也可以按上面方法更換
後來真正解決問題的是添加了缺失的頭文件
複製內容保存爲compiler-gcc5.h,放在要編譯內核模塊的內核代碼的include/linux下