在X86的机器上编译安装android,做一个简单快速的上网本.我的编译环境为VMwave+ubuntu10.04,编译时对内存占用很大,建议多分一点儿,我分了1.5G.参考网站:
android-x86官方网站:http://www.android-x86.org/
Google OS实验室:http://blog.livedoor.jp/moonlight_aska/
一、编译环境配置:
1、安装必要组件
$ sudo apt-get update
$ sudo apt-get -y install git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev valgrind
2、安装repo
$ cd ~
$ mkdir bin
$ curl http://android.git.kernel.org/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=$PATH:~/bin
二、获取android-x86源代码
$ mkdir android2.1
$ cd android2.1
$ repo init -u git://git.android-x86.org/platform/manifest.git -b eclair-x86
$ repo sync
-b eclair-x86为制定版本,这里采用的是2.1-eclair来编译的
三、开始编译,一般机器采用eeepc的模式编译。
$ cd android2.1
$ make iso_img TARGET_PRODUCT=eeepc
iso_img为打包为ISO镜像,如果想打包为USB镜像的话可以采用:
$ cd android2.1
$ make usb_img TARGET_PRODUCT=eeepc
错误修正:在编译的过程中碰到了几处错误,修改方法如下:
错误1、错误提示:
host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): in function thread_store_set:system/core/libcutils/threads.c:36: error: undefined reference to 'pthread_key_create'
/usr/bin/ld: out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): in function thread_store_set:system/core/libcutils/threads.c:44: error: undefined reference to 'pthread_setspecific'
/usr/bin/ld: out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): in function thread_store_get:system/core/libcutils/threads.c:27: error: undefined reference to 'pthread_getspecific'
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] 错误 1
解决方法:修改./framework/base/tools/aapt/Android.mk文件
LOCAL_LDLIBS := -lz
ifeq ($(HOST_OS),linux)
-LOCAL_LDLIBS += -lrt
+LOCAL_LDLIBS += -lrt -lpthread
endif
ifeq ($(HOST_OS),windows)
错误2、错误提示:
host C++: acc <= system/core/libacc/tests/main.cpp
host C++: libacc <= system/core/libacc/acc.cpp
host SharedLib: libacc (out/host/linux-x86/obj/lib/libacc.so)
host Executable: acc (out/host/linux-x86/obj/EXECUTABLES/acc_intermediates/acc)
/usr/bin/ld: out/host/linux-x86/obj/EXECUTABLES/acc_intermediates/main.o: in function symbolLookup(void*, char const*):system/core/libacc/tests/main.cpp:41: error: undefined reference to 'dlsym'
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/acc_intermediates/acc] 错误 1
解决方法:修改./system/core/libacc/tests/Android.mk文件
LOCAL_SHARED_LIBRARIES :=
libacc
+LOCAL_LDLIBS := -ldl
#LOCAL_MODULE_TAGS := tests
LOCAL_SHARED_LIBRARIES :=
libacc
+LOCAL_LDLIBS := -ldl
LOCAL_CFLAGS := -O0 -g
LOCAL_SHARED_LIBRARIES :=
libacc
+LOCAL_LDLIBS := -ldl
LOCAL_MODULE_TAGS := tests
LOCAL_SHARED_LIBRARIES :=
libacc
+LOCAL_LDLIBS := -ldl
LOCAL_CFLAGS := -O0 -g
错误3、错误提示:
host Executable: localize (out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize)
/usr/bin/ld: out/host/linux-x86/o