准备工作:获取andriod2.3.1的源码包,以及对应的jdk1.6.0.26.
1、编译andriod2.3.1需要gcc4.4的版本,但是ubuntu14.04自带的版本比这个高。需要通过以下指令进行设置。
2、安装必要的软件包sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib
cd /usr/bin
ln -s gcc-4.4 gcc
ln -s g++-4.4 g++
gcc -v
g++ -v
sudo apt-get install git-coregnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-devbuild-essential zip curl libncurses5-dev zlib1g-dev valgrind
3、jdk的安装和配置
安装好jdk后(注意:要根据主机的类型选择合适的jdk安装包),需要进行如下配置。
sudo vi /etc/profile 添加以下内容:
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_26
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_26 /bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_26 /bin/javac 300
sudo update-alternatives --config java
4、Andriod的编译
(1)、解压源码包
tar -jxvfandroid_gingerbread_realv210_ver_1_0.tar.bz2
(2)、编译ubootcdandroid_gingerbread_realv210_ver_1_0/bootable/uboot_smdkv210/
./build
编译过程中遇到以下问题:在Ubuntu14.04 64位系统中已经安装了libc6:i386的库,编译Uboot时提示error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory.
解决方法:
sudo apt-get install lib32z1
这样在uboot_smdkv210下将得到u-boot.bin文件。
(3)、编译andriod
在终端下进入andriod_gingerbread_realv210_ver_1_0目录,运行下面命令完成andriod的编译。
./build_andriod
编译过程中遇到以下问题:
问题1:
Checking build tools versions...
build/core/main.mk:76: ************************************************************
build/core/main.mk:77: You are attempting to build on a 32-bit system.
build/core/main.mk:78: Only 64-bit build environments are supported beyond froyo/2.2.
build/core/main.mk:79: ************************************************************
build/core/main.mk:80: *** stop. Stop
解决方法:
vi build/core/main.mk 将下面的部分:
73 ifeq ($(BUILD_OS),linux)
74 build_arch := $(shell uname -m)
75 ifneq (i686,$(findstring i686,$(build_arch)))
76 $(warning ************************************************************)
77 $(warning You are attempting to build on a 32-bit system.)
78 $(warning Only 64-bit build environments are supported beyond froyo/2.2.)
79 $(warning ************************************************************)
80 $(error stop)
81 endif
82 endif
改为如下所示:
73 ifeq ($(BUILD_OS),linux)
74 build_arch := $(shell uname -m)
75 # ifneq (i686,$(findstring i686,$(build_arch)))
76 # $(warning ************************************************************)
77 # $(warning You are attempting to build on a 32-bit system.)
78 # $(warning Only 64-bit build environments are supported beyond froyo/2.2.)
79 # $(warning ************************************************************)
80 # $(error stop)
81 # endif
82 endif
即可解决上述问题1。
问题2:
dalvik_system_Zygote.c:191:19: error: storage size of 'rlim' isn't known
解决方法如下:
添加头文件#include <sys/resource.h>到以下文件
dalvik/vm/native/dalvik_system_Zygote.cpp
问题3:
/usr/include/zlib.h:34:19: fatal error: zconf.h: No such file or directory
解决方法如下:
sudo ln -sfn /usr/include/x86_64-linux-gnu/zconf.h /usr/include/
问题4:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../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/lib/libneo_cgi.so] Error 1
解决方法如下:
sudo apt-get install lib32z1-dev
sudo apt-get install zlib1g-dev
(4) 编译完成
出现以下信息说明编译完成:
Total compile time is 16 seconds
[[[[[[[ Make ramdisk image for u-boot ]]]]]]]
ok success !!!
编译结束后便可以在android_gingerbread_realv210_ver_1_0/out/target/product/smdkv210下得到kernel.img , ramdisk-yaffs.img , userdata.img , system.img等镜像文件,分别是linux内核镜像文件,根文件系统镜像,data分区镜像,system分区镜像。