Tuesday, September 6, 2011

complie Android source to emulator

依照android source的指示, 但安裝所需套件時, 參考以下套件
Ubuntu Linux (32-bit x86):
sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

Ubuntu Linux (64-bit x86):
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

java5 is for Froyo, java6 is for gingerbread
complie完之後,if we want to run emulator. 在environment path中加上"ANDROID_PRODUCT_OUT=target/product/generic"
and exec "./out/host/linux-x86/bin/emulator"

if use gcc4.6 to compile Donut, also need to change some things.reference Here
change ./frameworks/base/libs/utils/Android.mk
from
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
to
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

change ./development/emulator/qtools/Android.mk
from
common_cflags := -O0 -g
to
common_cflags := -O0 -g -Wwrite-strings -fpermissive

Change ./frameworks/base/tools/localize/Android.mk
from
LOCAL_LDLIBS += -lrt
to
LOCAL_LDLIBS += -lrt -lpthread

change frameworks/base/tools/appt/Android.mk
from
LOCAL_LDLIBS += -lrt
to
LOCAL_LDLIBS += -lrt -lpthread

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp :0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] :0:0: note: this is the location of the previous definition cc1plus: all warnings being treated as errors make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1 To fix this, refer to this patch. https://github.com/CyanogenMod/android_build/commit/e9cbfa60c8dd60d04570d8bf7bd0d54a4304baf5 It will patch line 61 in build/core/combo/HOST_linux-x86.mk as following. -HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 +HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1 change external/mesa3d/src/glsl/linker.cpp Adding a "#include
from
unsigned output_index = offsetof(VertexOutput,varyings) / sizeof(Vector4); /*VERT_RESULT_VAR0*/;
to
unsigned output_index = offsetof(VertexOutput,varyings) / sizeof(Vector4); /*VERT_RESULT_VAR0;*/


make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1
change external/oprofile/libpp/format_output.h
from
mutable counts_t & counts;
to
counts_t & counts;

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error change external/gtest/include/gtest/internal/gtest-param-util.h
add
#include <cstddef>

make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1
change external/llvm/llvm-host-build.mk
add
LOCAL_LDLIBS := -lpthread -ldl

查看編譯版本等資訊
getprop




on Mac OS
Mac OS:10.6.6(snow leopard)
xCode: 
4.3.3 (10G)
macport:for snow leopard
gmake:3.81

download and install package by step on Android source website.
1. need HFS+ disk format and disk size is suppose be bigger 25G.
2. download xCode.(4.2G). Build Android needs macOS.sdk 10.6. If download xCode4.5, it will not include MacOS10.6. It still need to download old version xCode to get 10.6SDK.
3. setup macport and install some packages (see Android source doc)
4. change gmake version to 3.81
5. Download source code in HFS disk
6. change JDK1.5, snow leopard uses 1.6 by default.
7. Change the gcc alias. This is needed by Qemu.

sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-4.0 /usr/bin/gcc
8. To fix this error go to “external/qemu/” and open Makefile.Android file and edit the following line
MY_CC := $(HOST_CC)
to
MY_CC := gcc
9.

No comments:

Post a Comment