以下是我自己编译4.0时遇到的错误,内容大部分收集与于网络
错误1
error: "_FORTIFY_SOURCE" redefined [-Werror]
解决办法:
build/core/combo/HOST_linux-x86.mk line 61:
把:
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
改为:
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
参考:http://code.google.com/p/android/issues/detail?id=20795
错误2
counts_t & counts;
错误3
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_dev’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::__pad1’ [-Wmissing-field-initializers]
...
...
...
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_ino’ [-Wmissing-field-initializers]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1
解决方法
external/gtest/include/gtest/internal/gtest-param-util.h
add
#include <cstddef>
错误4
frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable] cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs_export_foreach.o]
解决方法:
frameworks/compile/slang/Android.mk -local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror +local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter
错误5
undefined reference to `pthread_mutexattr_destroy'
host C++: libgtest_host <= external/gtest/src/gtest-all.cc
host C++: libgtest_main_host <= external/gtest/src/gtest_main.cc
...
...
...
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock'
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1
make: *** Waiting for unfinished jobs....
解决方法:
$vi external/llvm/llvm-host-build.mk
LOCAL_LDLIBS := -lpthread -ldl
问题6(2.3.7)
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
解决方法:
打开Android.mk
$ gedit frameworks/base/libs/utils/Android.mk
将下面这一行
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
改为
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
错误7(2.3.7)
错误:make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] 错误 1
make: *** 正在等待未完成的任务....
解决方法:修改源码目录下/build/core/combo/HOST_linux-x86.mk文件:
将以下语句
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
修改为
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
错误8
make: *** [out/target/common/obj/APPS/CtsVerifier_intermediates/classes-full-debug.jar] Error 41
make: Leaving directory `/media/zhaodezhong/study/ics_source'
原因分析:原因不详,忘高人指教。。。
解决办法:在网上查了些资料,知道CTS 全称Compatibility Test Suite兼容性测试工具。当电子产品开发出来,并定制了自己
的Android系统后,必须要通过最新的CTS检测,以保证标准的android application能运行在该平台下。通过了CTS验证,需要将
测试报告提交给Google,已取得android market的认证。感觉对android自身运行关系不大,所以干脆不编译这块内容了。
找到cts/下的Android.mk文件,注释掉里面两行代码
#include cts/CtsTestCoverage.mk
#include $(call all-subdir-makefiles)
整个cts/下的代码都不编译了,OK,这个问题解决就编译通过了。