编译源码在源码目录下make即可。
错误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 解决:
1 | gedit frameworks/base/libs/utils/Android.mk |
错误2: host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt) out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_get’: /home/leno/works/android_dev/bin/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’: /home/leno/works/android_dev/bin/system/core/libcutils/threads.c:36: undefined reference to `pthread_key_create’ /home/leno/works/android_dev/bin/system/core/libcutils/threads.c:44: undefined reference to `pthread_setspecific’ collect2: ld returned 1 exit status make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] 错误 1 解决:
1 | gedit frameworks/base/tools/aapt/Android.mk |
错误 3: out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_get’: /home/leno/works/android_dev/bin/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’: /home/leno/works/android_dev/bin/system/core/libcutils/threads.c:36: undefined reference to `pthread_key_create’ /home/leno/works/android_dev/bin/system/core/libcutils/threads.c:44: undefined reference to `pthread_setspecific’ collect2: ld returned 1 exit status make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize] 错误 1 解决:
1 | gedit frameworks/base/tools/localize/Android.mk |
错误4: 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 解决:
1 | gedit system/core/libacc/tests/Android.mk |
OK!!收工
编译Android 2.3时出现的错误:
错误1 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 解决方法:
1 | gedit build/core/combo/HOST_linux-x86.mk |