在x86的机器上编译使用Andorid
来源:互联网 发布:联合国工作 知乎 编辑:程序博客网 时间:2024/05/15 12:20
在x86的机器上编译使用Andorid
转自:http://www.cnbeta.com/articles/118504.htm
在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 bisongperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zipcurl 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 -beclair-x86
$ repo sync
-b eclair-x86为制定版本,这里采用的是2.1-eclair来编译的
注:对于下载的时间,个人认为凌晨12点以后到中午12点之间速度较快。
三、开始编译,一般机器采用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: infunction symbolLookup(void*, charconst*):system/core/libacc/tests/main.cpp:41: error: undefinedreference 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/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/localize_intermediates/localize]错误 1
解决方法:修改./framework/base/tools/localize/Android.mk文件
libcutils
ifeq ($(HOST_OS),linux)
-LOCAL_LDLIBS += -lrt
+LOCAL_LDLIBS += -lrt -lpthread
endif
编译成功后,可在out/target/product/eeepc/eeepc.iso找到ISO镜像,用虚拟机载入该镜像即可。
已知不完善的地方,gapps安装后会FC,电子市场FC
键位绑定:
鼠标左键:点击
鼠标中键:menu
鼠标右键/键盘ESC:返回
键盘Home键:home键
================================================
补充:
1. 下载的过程比较痛苦,因为下载速度很慢,而且容易断网。后来发现凌晨到上午这段时间比较快。虽然断网现象仍在,但速度快了很多。
2. 上面的变异并没有遇到错误,可能是改正过来了吧。
3. 在本机上实验generic_x86
Choose a target
You need to choose a target for the x86 device you want touse/test. We provides several targets for different branches:
donut-x86
eeepc: for ASUS EeePC family
q1u: for Samsung Q1U
s5: for Viliv S5
eclair-x86
generic_x86: for generic x86 PC/notebook
eeepc: for ASUS EeePC family only
q1u: for Samsung Q1U
s5: for Viliv S5
froyo-x86
generic_x86: for generic x86 PC/notebook
eeepc: for ASUS EeePC family only
vm: for virtual machine (virtual box, qemu, vmware)
Actually, for historical reason, you have to use eeepc for ageneric x86 PC, notebook or netbook before (includes) donut-x86branch. Since eclair-x86 branch, eeepc is changed to serve ASUSEeePC family only. Do not use it if you are not using anEeePC.
In short, if you don't know how to choose, use eeepc for donut-x86branch, and use generic_x86 for eclair-x86 or later branches.
If the computer you build on has more then one processor orcore, you can take advantage of multiprocessing (or make jobs) byadding -jX to the beginning of your make command:
$ make -jX usb_img TARGET_PRODUCT=eeepc
Replace X by the number of processors you have. For example, ifyou have a quad core CPU, replace X with 4:
$ make -j4 usb_img TARGET_PRODUCT=eeepc
根据上面的提示,eclair-x86以后版本都可以使用generic_x86作为TARGET_PRODUCT,但是从哪个网站上看见说这个iso只能用于虚拟机,没有验证过,所以不知道真假。
make iso_img TARGET_PRODUCT=generic_x86
遇见错误及解决:
target StaticLib: libwebcore(out/target/product/sapphire-open/obj/STATIC_LIBRARIES/libwebcore_intermediates/libwebcore.a)
make: execvp: /bin/bash: Argument list too long(中文的错误信息是"参数列项目过长")
make: ***[out/target/product/sapphire-open/obj/STATIC_LIBRARIES/libwebcore_intermediates/libwebcore.a]
解决:
cd external/webkit
git cherry-pick 18342a41ab72e2c21931afaa
信息提示:
root@ubuntu:~/work/android-x86-21/external/webkit#git cherry-pick 18342a41ab72e2c21931afaa
Finished one cherry-pick.
[detached HEAD f0d0424] Fix spurious build breaks.
Author: Patrick Scott <phanna@android.com>
Committer: root <root@ubuntu.(none)>
Your name and email address were configured automaticallybased
on your username and hostname. Please check that they areaccurate.
You can suppress this message by setting them explicitly:
If the identity used for this commit is wrong, you can fix itwith:
2 files changed, 28 insertions(+), 14 deletions(-)
继续编译,没再遇到问题,最后信息:
Total translation table size: 4495
Total rockridge attributes bytes: 1372
Total directory bytes: 3158
Path table size(bytes): 26
Done with: TheFile(s)
Writing:
Done with: EndingPadblock
Max brk space used 0
254217 extents written (496 MB)
在out/target/product/generic_x86/目录下生成genetic_x86.iso,及initrd.img/install.img/ramdisk.img/system.img等镜像文件。
- 在x86的机器上编译使用Andorid
- 在x86的机器上编译使用Andorid
- 在x86架构机器上交叉编译linux内核方法
- windows编译的库无法在其他机器上使用
- OProfile在Andorid上使用
- 在X86上交叉编译ARM64 linux上的NCNN
- 交叉编译在x86上调试好的qt程序
- Cocos2d-js-v3.2 在 mac 上配置环境以及编译到 Andorid 的注意事项
- 在x86机器的屏幕上显示的三种方法
- 在 x86 上面交叉编译 gstreamer for arm(zz)与MIPS平台上的编译(原)
- 程序运行在X86和X64机器上由字节分配不一样引发的问题
- X86平台上的TCPMP编译过程
- 在32位的机器上编译Android
- 关于uc/os-II在x86上的编译与调试
- vs2005编译的release MFC程序无法在未安装2005的机器上使用的问题解决
- OProfile在Andorid上使用以及PC分析环境
- 在Fedora7上编译qtopia-2.2.0 x86版
- C#使用_如何在没有装VS(Visual Studio)的机器上编译运行C#程序
- Android HAL实践(一):Mini6410…
- Android HAL实践(一):Mini6410…
- 解决lib只读的问题
- 解决lib只读的问题
- 在x86的机器上编译使用Andorid
- 在x86的机器上编译使用Andorid
- virtualbox 虚拟机 ubuntu中下添加…
- virtualbox 虚拟机 ubuntu中下添加…
- Errors when building android-gin…
- Errors when building android-gin…
- JNI数组传递与异常处理
- JNI数组传递与异常处理
- java字符串转化
- java字符串转化