android内核源码编译个人方法和错误记录

来源:互联网 发布:sql server 2000 4in1 编辑:程序博客网 时间:2024/05/01 17:09

下载源码

git clone需要翻墙,下下来之后通过branch和checkout获得内核源码

找到ndk路径

一般gcc交叉编译器位于ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin
(版本可能不同)
通过export PATH=$PATH:xxxxxx/ndk/toolchains/….. 将其设置为环境变量,以免找不到编译器

配置makefile

找到makefile中的
ARCH和CROSS_COMPILE
分别设置为

ARCH ?= armCROSS_COMPILE ?= arm-linux-androideabi-

make menuconfig

make menuconfig

错误1

出现一大堆”/r”什么什么的错误

原因

是在windows下下载的代码,我的环境是linux,涉及到换行符不同的问题

解决方法

在linux下解压,甚至重新下载(我是重新下载的),然后tar解压

make

错误1

fatal error: linux/compiler-gcc6.h: No such file or directory #include gcc_header(__GNUC__)

原因

没有配置makefile

解决方法

在makefile中配置ARCH和CROSS_COMPILE

错误2

arm-linux-androideabi-gcc: not found/root/projects/linux_source/goldfish/./Kbuild:35: recipe for target 'kernel/bounds.s' failed

原因

没有将交叉编译器路径加入PATH变量

解决方法

通过之前的方法,在PATH里边加入交叉编译器路径

错误3

arm-linux-androideabi-ld: internal error in relocate_special_relocatable, at /usr/local/google/buildbot/src/android/gcc/toolchain/build/../binutils/binutils-2.25/gold/arm.cc:10544scripts/Makefile.build:308: recipe for target 'arch/arm/kernel/traps.o' failed

原因

我也不清楚..好像是编译器什么的没有设置好

解决方法

make menuconfig选择kernel Features --->勾选以下两个,保存                  [*] Use the ARM EABI to compile the kernel                  [*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL)  

错误4

ernel/fork.c: In function 'copy_seccomp':kernel/fork.c:1134:2: error: implicit declaration of function 'task_no_new_privs' [-Werror=implicit-function-declaration]  if (task_no_new_privs(current))  ^kernel/fork.c:1135:3: error: implicit declaration of function 'task_set_no_new_privs' [-Werror=implicit-function-declaration]   task_set_no_new_privs(p);   ^cc1: some warnings being treated as errors

原因

好像是版本问题,导致这里认为没有声明就被使用了

解决方法

我不知道怎么通过标准方法解决,不知道那个-Werror=implicit-function-declaration怎么用,所以我直接进代码,然后补充了两个函数声明.
根据其位置和参数添加两个声明.

错误5

出现了 too few arguments

原因

应该也是版本问题造成的,可能是include的.h文件和当前文件的版本不一样,导致更新的东西这边没有,然而这种问题已经不能简单的通过之前一样来解决了

解决方法

这个已经不能简单的更改代码解决了,因为可能涉及到一些更深层次的问题,要么通过查看源码,自己进行更新,要么采取终极解决方案,换一套源码.因为这种情况肯定已经不是应该出现的问题了,而我,采用了后者

0 0
原创粉丝点击