编译环境:MAC OS 10.8.2 xcode 4.5
编译命令:
source build/envsetup.sh
choosecombo
lunch
make CC=gcc CXX=g++ -j4
编译过程中可能遇到的问题解决参考如下,声明以下解决方案仅供参考,操作系统环境不一样,会导致出现不一样的问题。
1.问题:Please install the 10.5 SDK on this machine at /Developer/SDKs/MacOSX10.5.sdk
external/qemu/Makefile.android:82: *** Aborting the build.. Stop.
解决方案:
(1)Open external/qemu/Makefile.android
ifeq ($(HOST_OS),darwin)
MY_CFLAGS += -mdynamic-no-pic -D_DARWIN_C_SOURCE=1
# When building on Leopard or above, we need to use the 10.4 SDK
# or the generated binary will not run on Tiger.
DARWIN_VERSION := $(strip $(shell sw_vers -productVersion))
ifneq ($(filter 10.1 10.2 10.3 10.1.% 10.2.% 10.3.% 10.4 10.4.%,$(DARWIN_VERSION)),)
$(error Building the Android emulator requires OS X 10.5 or above)
endif
ifeq ($(filter
10.8
10.8
.%,$(DARWIN_VERSION)),)
# We are on Snow Leopard or above
#LEOPARD_SDK := /Developer/SDKs/MacOSX10.5.sdk
LEOPARD_SDK := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
ifeq ($(strip $(wildcard $(LEOPARD_SDK))),)
$(info Please install the 10.8 SDK on this machine at $(LEOPARD_SDK))
$(error Aborting the build.)
endif
MY_CFLAGS += -isysroot $(LEOPARD_SDK) -mmacosx-version-min=10.5 -DMACOSX_DEPLOYMENT_TARGET=10.8
MY_LDLIBS += -isysroot $(LEOPARD_SDK) -Wl,-syslibroot,$(LEOPARD_SDK) -mmacosx-version-min=10.5
endif
endif
2.问题:frameworks/base/include/utils/KeyedVector.h:193:17: error: use of undeclared identifier 'indexOfKey'
ssize_t i = indexOfKey(key);
解决方案:
Add a scopre resolution operator 'this->' like:
frameworks/base/include/utils/KeyedVector.h:193
template<typename KEY, typename VALUE> inline
const VALUE& DefaultKeyedVector<KEY,VALUE>::valueFor(const KEY& key) const {
ssize_t i = this->indexOfKey(key);
return i >= 0 ? KeyedVector<KEY,VALUE>::valueAt(i) : mDefault;
3.问题:external/srec/tools/thirdparty/OpenFst/fst/lib/vector-fst.h:325:3: error: use of undeclared identifier 'SetInputSymbols'
SetInputSymbols(fst.InputSymbols());
^
this->
解决方案:
安装gcc45,select gcc,切换到llvm-gcc-4.2,使用编译命令如下;
port select gcc //输出当前支持的gcc版本
port select gcc llvm-gcc-4.2//选择xcode安装的编译器
4.问题:
dyld: lazy symbol binding failed: Symbol not found: __ZNKSt5ctypeIcE13_M_widen_initEv
Referenced from: /Volumes/android/ICS/out/host/darwin-x86/bin/grxmlcompile
Expected in: /usr/lib/libstdc++.6.dylib
解决方案:
export DYLD_LIBRARY_PATH="/usr/gcc-4.4/lib:$DYLD_LIBRARY_PATH"
5.问题:
In file included from /System/Library/Frameworks/IOKit.framework/Headers/usb/IOUSBLib.h:27,
from system/core/adb/usb_osx.c:21:
/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h:580: error: too many #pragma options align=reset
解决方案:修改文件/System/Library/Frameworks/IOKit.framework/Headers/usb/USB.h
将#pragma options align=reset替换为#pragma pack(),如下(共5处):
//#pragma options align=reset
#pragma pack()
6.问题:GCC is not recognizing command line option "-mdynamic-no-pic"
解决方案:修改文件external/qemu/Makefile.android
ifeq ($(HOST_OS),darwin)
#MY_CFLAGS += -mdynamic-no-pic -D_DARWIN_C_SOURCE=1
MY_CFLAGS += -ObjC -D_DARWIN_C_SOURCE=1
7.问题:Objective-C compiler not installed on this system mac
解决方案:切换到gcc45
8.问题:在Android 系统下面,编译 cpp 程序的时候,在程序link 的时候,遇到过类似的错误:
missing: vtable for __cxxabiv1::__si_class_type_info
这个错误是由于在编译的过程中没有支持编译起 no-rtti ,只要在编译的时候在 CFLAGS += -fno-rtti -fno-exceptions
既可以解决这个问题.具体如下:
修改文件external/qemu/Makefile.android
ifeq ($(HOST_OS),darwin)
#MY_CFLAGS += -mdynamic-no-pic -D_DARWIN_C_SOURCE=1
MY_CFLAGS += -fno-rtti -fno-exceptions -D_DARWIN_C_SOURCE=1
9.问题:
host SharedLib: libSR_Recognizer (out/host/darwin-x86/obj/lib/libSR_Recognizer.dylib)
Undefined symbols for architecture i386:
"_pushAudioIntoRecognizer", referenced from:
_SR_RecognizerAdvanceImpl in RecognizerImpl.o
解决方案:
vi ./external/srec/srec/Recognizer/src/RecognizerImpl.c
replace all PINLINE
with /*** PINLINE ***/
- actually remove all of them
10.问题:
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libext_intermediates/libxt_connmark.o] Error 1
make: *** Waiting for unfinished jobs....
分析原因:我是在windows下用rar解压tar包的,在解压过程中有文件丢失。偷懒的坏处!
解决办法:到linux/netfilter/下发现确实没有xt_connmark.h文件,重新在linux下解压源码的tar包。
或者使用以下链接 http://www.oschina.net/code/explore/iptables-1.4.10/include/linux/
11.问题:
Undefined symbols:
"__dyld_func_lookup", referenced from:
_promoteLocalToGlobal in libSDL.a(SDL_dlcompat.o)
解决方案:修改文件external/qemu/Makefile.android
ifeq ($(HOST_OS),darwin)
QEMU_SYSTEM_LDLIBS += -Wl,-framework,Cocoa /usr/lib/dylib1.10.5.o
endif
参考:http://hi.baidu.com/cadence2004/item/753ef00a8c8a1b7cd45a11be
主要步骤如下: 请看第4步
1 安装xcode 3.2.6(安装目录为/xcode326)
2 在/Developer/SDKs/建立一个软连接到/xcode326/SDKs/MacOSX10.5.sdk 取名为 MacOSX10.5.sdk;
3 回到android目录树,修改development/tools/emulator/opengl/host/renderer/Android.mk
找到LOCAL_LDLIBS += -lX11 在后面加上-L/Developer/SDKs/MacOSX10.5.sdk/usr/X11/lib 可以解决X11找不到的错误
4 修改development/tools/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
和development/tools/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
找到LOCAL_LDLIBS += $(LOCAL_SDL_LDLIBS),修改为LOCAL_LDLIBS += $(LOCAL_SDL_LDLIBS) /usr/lib/dylib1.10.5.o,这两个完全是测试例子,其实直接删除这两个文件也可以.
网上有人建议将external/qemu/Android.mk文件全部注释或者删除,此方法不可取,因为这样做你最后是得不到emulator这个可执行文件的,相当于大部分工作没做.
步骤4可以解决如下的错误:
Undefined symbols:
"__dyld_func_lookup", referenced from:
_promoteLocalToGlobal in libSDL.a(SDL_dlcompat.o)
_dlcompat_init_func in libSDL.a(SDL_dlcompat.o)
_dlcompat_init_func in libSDL.a(SDL_dlcompat.o)
_dlcompat_init_func in libSDL.a(SDL_dlcompat.o)
12.问题
注:如果未加sudo会出现如下错误:
/bin/bash: out/host/linux-x86/bin/mksnapshot:
make:*** [out/target/product/generic/obj/STATIC_LIBRARIES/libv8_intermediates/snapshot.cc]
解决方案:
Simply change ENABLE_V8_SNAPSHOT from true to false in external/v8/Android.mk and relaunch make.
13.问题:
localhost:ICS han$ strip -r /Volumes/android/ICS/out/host/darwin-x86/sdk/android-sdk_eng.han_mac-x86/tools/lib/libOpenglRender.dylib
strip: symbols referenced by indirect symbol table entries that can't be stripped in: /Volumes/android/ICS/out/host/darwin-x86/sdk/android-sdk_eng.han_mac-x86/tools/lib/libOpenglRender.dylib
解决方案:
修改文件/Volumes/android/ICS/sdk/build/tools.atree
# OpenGLES emulation libraries
lib/libOpenglRender${DLL_EXTENSION} strip -u tools/lib/libOpenglRender${DLL_EXTENSION}
14.问题;
sed: RE error: illegal byte sequence
解决方案:
localhost:ICS han$ unset LANG 再重新make