android4.0编译错误集(一)
1、Android library 'XXX.so' not in prelink map 错误解决
在编译自己的Android library时可能会出现
library 'XXX.so' not in prelink map 错误,
这是由于Android的预编译设置引起的,/build/core/prelink-linux-arm.map文件描述了预编译的模块
需要修改所在文件夹下的android.mk文件
增加
LOCAL_PRELINK_MODULE := false
将预编译关闭,即可通过。
2、错误一:error: ‘ptrdiff_t’ does not name a type
In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0,
from external/gtest/src/../include/gtest/gtest.h:69,
from external/gtest/src/gtest_main.cc:32:
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0,
from external/gtest/src/../include/gtest/gtest.h:69,
from external/gtest/src/../src/gtest.cc:34,
from external/gtest/src/gtest-all.cc:36:
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
In file included from external/gtest/src/gtest-all.cc:38:0:
解决方法:
$vi external/gtest/src/../include/gtest/internal/gtest-param-util.h
#include <cstddef>
3.错误二:undefined reference to `pthread_mutexattr_destroy'
host C++: libgtest_host <= external/gtest/src/gtest-all.cc
true
host C++: libgtest_main_host <= external/gtest/src/gtest_main.cc
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o): In function `PrintStackTrace':
/home/aa/project/android4.0.1/external/llvm/lib/Support/Unix/Signals.inc:219: undefined reference to `dladdr'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Unix/Signals.inc:231: undefined reference to `dladdr'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)':
/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:100: undefined reference to `pthread_join'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `MutexImpl':
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:69: undefined reference to `pthread_mutexattr_init'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:75: undefined reference to `pthread_mutexattr_settype'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:80: undefined reference to `pthread_mutexattr_setpshared'
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:89: undefined reference to `pthread_mutexattr_destroy'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()':
/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
下面这个解决方法没成功,会有新的错误:errors again :can't find threads.h file or dir.
$ vi external/llvm/lib/Support/Android.mk
LOCAL_C_INCLUDES += system/core/include/cutils
LOCAL_SHARED_LIBRARIES := libcutil
$ vi external/llvm/lib/Support/Mutex.cpp
#include <threads.h>
$ vi external/llvm/lib/Support/Threading.cpp
#include <threads.h>
4.错误三:error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]
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
解决方法:
$ vi 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、2.3以上系统使用JDK1.6,所以必须下载并设定其编译环境
vi ~/.bashrc
export JAVA_HOME=/usr/java/jdk1.6.0_23
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/bin/tools.jar:$JRE_HOME/bin
export ANDROID_JAVA_HOME=$JAVA_HOME
6、Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
解决:
内存不足
7、external/jsilver/src/com/google/streamhtmlparser/util/JavascriptTokenBuffer.java:80: cannot find symbol
symbol : method copyOf(char[],int)
解决:
把sdk从1.5升级到1.6
8、arm-eabi-4.4.3 version `GLIBC_2.11' not found
解决方法
prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-gcc -mthumb-interwork -Ibionic/libc/private -o out/target/product/generic/obj/lib/crtbegin_dynamic.o -c bionic/libc/arch-arm/bionic/crtbegin_dynamic.S
prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-gcc: /lib/tls/i686/cmov/libc.so.6: version `GLIBC_2.11' not found (required by prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-gcc)
make: *** [out/target/product/generic/obj/lib/crtbegin_dynamic.o] 错误 1
这是在32位Ubuntu上编译引起的arm-eabi-4.4.3版本问题,所以需要修改arm-eabi-4.4.0:
$ mv arm-eabi-4.4.3 to arm-eabi-4.4.3.old
$ ln -s arm-eabi-4.4.0 arm-eabi-4.4.3
or:
升级glibc或者系统
9、
PassFailButtons.java:191: onCreateDialog(int,android.os.Bundle) in android.app.Activity cannot implement onCreateDialog(int,android.os.Bundle) in com.android.cts.verifier.PassFailButtons.PassFailActivity; attempting to assign weaker access privileges;
解决:
很可能是因为使用了openjdk,而非sun-java6-jdk,
10、
undefined reference to __asprintf_chk
解决:
可能会由于stdio2.h导致编译错误。正确的stdio2.h是./prebuilt/linux-x86/toolchain/i686-linux-glibc2.7-4.4.3/sysroot/usr/bits/stdio2.h文件,请重新设置PATH环境变量,将./prebuilt/linux-x86/toolchain/i686-linux-glibc2.7-4.4.3/sysroot/usr放在PATH的最前。
cp ./prebuilt/linux-x86/ toolchain/i686-unknown-linux-gnu-4.2.1/lib/libbfd.a ./out/host/linux-
x86/obj/STATIC_LIBRARIES/libbfd_intermediates/libbfd.a
可能 glibc版本不是最新的
11、
SDL init failure, reason is: No available video device .
解决:
原因是他依赖X11,可以进入图形化界面来运行。
12、
In file included from frameworks/base/include/utils/Vector.h:26,
from frameworks/base/include/utils/Sort
补充:移动开发 , Android ,