sudo apt-get install ant ant-optional bison build-essential ca-certificates-java curl flex fusesmb g++-4.4-multilib g++-multilib gcc-4.4-multilib gcc-multilib git-core git-gui gitk gnuit gnupg gperf ia32-libs lib32ncurses5-dev libreadline-gplv2-dev
lib32readline-gplv2-dev lib32z1 lib32z1-dev libc6-dev-i386 libesd0-dev libmotif4 libncurses5-dev libsasl2-modules-gssapi-mit libsdl1.2-dev libx11-dev meld menu tsocks valgrind vim x11proto-core-dev zip zlib1g-dev
2、编译错误
1)
错误日志1
host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp
frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:
frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1
错误日志2
In file included from external/oprofile/libpp/arrange_profiles.cpp:24:0:
external/oprofile/libpp/format_output.h:94:22: 错误: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
错误日志3
In file included from external/oprofile/pp/opreport.cpp:32:0: external/oprofile/libpp/format_output.h:94:22: 错误: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive] In file included from external/oprofile/libpp/xml_utils.h:15:0, from external/oprofile/pp/opreport_options.cpp:26: external/oprofile/libpp/format_output.h:94:22: 错误: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
解决方法:修改 gedit frameworks/base/libs/utils/Android.mk
将:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
改为:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
修改文件
external/oprofile/libpp/Android.mk
external/oprofile/pp/Android.mk
将
LOCAL_CFLAGS := $(common_host_cflags)
改为
LOCAL_CFLAGS := $(common_host_cflags) -fpermissive
或者修改build/core/combo/HOST_linux-x86.mk
给HOST_GLOBAL_CFLAGS加上 -fpermissive
2)
链接错误
错误日志1
system/core/libcutils/threads.c:27: undefined reference to ‘pthread_getspecific'
out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_set':
system/core/libcutils/threads.c:36: undefined reference to ’pthread_key_create'
system/core/libcutils/threads.c:44: undefined reference to ‘pthread_setspecific'
collect2: ld 返回 1
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] 错误 1
错误日志2
out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_get':
system/core/libcutils/threads.c:27: undefined reference to `pthread_getspecific'
out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_set':
system/core/libcutils/threads.c:36: undefined reference to `pthread_key_create'
system/core/libcutils/threads.c:44: undefined reference to `pthread_setspecific'
collect2: true
Generating libraries.cc
python out/host/linux-x86/obj/EXECUTABLES/mksnapshot_intermediates/js2c.py out/host/linux-x86/obj/EXECUTABLES/mksnapshot_intermediates/libraries.cc out/host/linux-x86/obj/EXECUTABLES/mksnapshot_intermediates/libraries-empty.cc CORE external/v8/src/runtime.js external/v8/src/v8natives.js external/v8/src/array.js external/v8/src/string.js external/v8/src/uri.js external/v8/src/math.js external/v8/src/messages.js external/v8/src/apinatives.js external/v8/src/date.js external/v8/src/regexp.js external/v8/src/json.js external/v8/src/mirror-debugger.js external/v8/src/debug-debugger.js external/v8/src/macros.py
ld 返回 1
make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize] 错误 1
make: *** 正在等待未完成的任务....
解决方法:
修改make文件
frameworks/base/tools/aapt/Android.mk
frameworks/base/tools/localize/Android.mk
将这几句
ifeq ($(HOST_OS),linux)
LOCAL_LDLIBS += -lrt
endif
改为
ifeq ($(HOST_OS),linux)
LOCAL_LDLIBS += -lrt -lpthread
endif
3)
错误日志
<命令行>:0:0: 错误: “_FORTIFY_SOURCE”重定义 [-Werror]
解决方法
修改build/core/combo/HOST_linux-x86.mk
将
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
改为HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0