编译Android系统源码和内核源码(2)


今天在Ubuntu 11.04(64位)编译Android2.3源码时,遇到各种各样的问题。不是缺这个,就是少那个。现把这些问题和解决方法罗列出来,供大家参考

普遍错误:
1.错误:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] 错误 1
解决:
sudo apt-get install libc6-dev-i386

2.错误:
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp] error 1
解决:
sudo apt-get install g++-multilib

3.错误:
external/clearsilver/cgi/cgi.c:22: fatal error: zlib.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] Error 1
解决:
sudo apt-get install zlib1g-dev

4.错误:
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1
解决:
sudo apt-get install lib32z1-dev

5.错误:
bison -d  -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
/bin/bash: bison: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127
解决:
sudo apt-get install bison

6.错误:
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
/bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
解决:
sudo apt-get install flex

7.错误:
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
解决:
sudo apt-get install lib32ncurses5-dev

8.错误:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/main-common.o] Error 1
解决:
sudo apt-get install libx11-dev

9.错误:
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 96.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h'
解决:
sudo apt-get install gperf

致命错误: bits/predefs.h:没有那个文件或目录 编译中断

解决方法:
sudo apt-get install gcc-multilib

还有一个原因:

Ubuntu 11.10以上的gcc版本是4.6.1,版本太高,编译android时出错,要把gcc版本改为4.4.3

sudo apt-get install gcc-4.4
sudo apt-get install g++-4.4

总结错误

1.错误

host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.a when searching for -lz
/usr/bin/ld: skipping incompatible //usr/lib/libz.so when searching for -lz
/usr/bin/ld: skipping incompatible //usr/lib/libz.a when searching for -lz
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1

解决办法:

缺少lib32z1-dev,安装即可:apt-get install lib32z1-dev

2.错误
编译时出现 /usr/include/gnu/stubs.h:7: fatal error: gnu/stubs-32.h: No such file or directory 错误信息
/usr/include/gnu/stubs.h:7: fatal error: gnu/stubs-32.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] Error 1
解决办法:

缺少libc开发包,安装即可: apt-get install libc6-dev-i386

3.错误
Android编译遇到错误/usr/bin/ld: cannot find -lstdc++的解决
解决办法:

缺少g++-multilib库,安装即可: apt-get install g++-multilib 

最后发现的一个错误:

make android 时的 libwebcore.so error

解决办法:增加文件swap

参考: 

好吧在这上面的工作都做完了,错误也都解决了,编译也完成了,我是在晚上进行编译的,第二天好了,当看到结果的时候真的很开心:

Target system fs image:    out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Install system fs image: out/target/product/generic/system.img
Target ram disk: out/target/product/generic/ramdisk.img
Target userdata fs image: out/target/product/generic/userdata.img
Installed file list: out/target/product/generic/installed-files.txt

那么下面就运行一下编译的结果吧:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5f18c52222c8aeb1b6037e45419d0757.html