欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 旅游 > 编译Kernel时遇到“error: ‘linux/compiler_types.h‘ file not found“的解决方法

编译Kernel时遇到“error: ‘linux/compiler_types.h‘ file not found“的解决方法

2025/2/23 14:23:24 来源:https://blog.csdn.net/MrJonathan/article/details/143459095  浏览:    关键词:编译Kernel时遇到“error: ‘linux/compiler_types.h‘ file not found“的解决方法

问题描述:

在下载了一份安卓13项目的代码后进行make bootimage编译时遇到了下面编译报错:

In file included from /home/bspuser/scode/kernel/msm-4.19/include/uapi/linux/stat.h:5:
In file included from /home/bspuser/scode/kernel/msm-4.19/include/uapi/linux/types.h:14:
In file included from /home/bspuser/scode/kernel/msm-4.19/include/uapi/linux/posix_types.h:5:
/home/bspuser/scode/kernel/msm-4.19/include/uapi/linux/stddef.h:2:10: fatal error: 'linux/compiler_types.h' file not found
#include <linux/compiler_types.h>^~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.
make[3]: *** [scripts/Makefile.host:107: scripts/mod/modpost.o] Error 1
make[3]: *** Waiting for unfinished jobs....

两种无效解决办法:

先后尝试了两个网上的建议均无法解决上面报错,两个无效建议如下:

1、方法一:(验证无效)

sudo cp -rf kernel/msm-4.14/include/linux /usr/include/x86_64-linux-gnu/

执行此操作后,编译报错仍然存在

2、方法二:(验证无效)

进入kernel代码目录下执行:make headers_install ARCH=arm64 INSTALL_HDR_PATH=/usr

执行此操作后,编译报错仍然存在

最终有效解决方法:

方法三:(验证有效

在kernel-4.19(或kernel-4.14)代码目录下scripts/mod/Makefile文件中添加一行即可解决此问题

diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
index e014b2fdd069..cd62ffe2afb4 100644
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -7,6 +7,8 @@ always          := $(hostprogs-y) empty.omodpost-objs   := modpost.o file2alias.o sumversion.o+HOSTCFLAGS_modpost.o := $(LINUXINCLUDE)
+devicetable-offsets-file := devicetable-offsets.h$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s FORCE

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词