Ubuntu20 android编译环境踩坑日记 -- kernel

本文记录了在Ubuntu20环境下编译Android Q的Kernel4.19时遇到的问题及解决方法。主要问题是找不到<linux/compiler_types.h>头文件,该文件在编译过程中被多层引用。由于Ubuntu20的Kernel版本较高,解决方案是在/usr/include/sys/stat.h中注释掉对statx.h的包含,以规避此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ubuntu20 android编译环境踩坑日记 – kernel

ubuntu20 最新的kernel版本

$ cat /proc/version
Linux version 5.4.0-42-generic (buildd@lgw01-amd64-038) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020

在编译 android Q 的kernel4-19 的时候,会提示找不到 <linux/compiler_types.h> 头文件.
该头文件的引用关系:

/usr/include/sys/stat.h --> /usr/include/bits/statx.h --> linux/stat.h(android工程里的) --> linux/types.h --> linux/posix_types.h --> linux/stddef.h --> linux/compiler_types.h

但是在kernel-4.19的uapi/linux 下没有这个文件.对比 ubuntu14 的 stat.h 文件,发现没有 include statx.h,因此我们怀疑是 ubuntu20 的 kernel 版本号太高导致,如果不想对主机的kernel进行降级,那么可以在 /usr/include/sys/stat.h 中注释调 statx.h 来规避问题.

// /usr/include/sys/stat.h
/*#ifdef __USE_GNU
# include <bits/statx.h>
#endif*/
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值