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/SortedVector.h:24,
                 from frameworks/base/include/utils/KeyedVector.h:24,
                 from frameworks/base/include/media/AudioParameter.h:21,
                 from frameworks/base/media/libmedia/AudioParameter.cpp:22:
frameworks/base/include/utils/TypeHelpers.h:33: error: template with C linkage
解决:
将definitionss.mk 文件中transform-cpp-to-o -isystem 改为 -I  如果有 -isystem好像其指定的目录
会当作标准系统库目录
后面又出现类似问题,干脆将这个文件中所有的-isystem都改成了-I


13、
external/icu4c/common/rbbi.cpp:295: error: cannot use typeid with -fno-rtti
external/icu4c/common/rbbi.cpp:295: error: cannot use typeid with -fno-rtti
解决:
去掉definitionss.mk 文件中 define transform-cpp-to-o 中的-fno-rtti \  行


16、
abi/cpp/include/cxxabi.h:44: error: invalid use of incomplete type 'struct std::type_info'
<built-in>:0: error: forward declaration of 'struct std::type_info'
abi/cpp/include/cxxabi.h:51: error: invalid use of incomplete type 'struct std::type_info'
<built-in>:0: error: forward declaration of 'struct std::type_info'
abi/cpp/include/cxxabi.h:58: error: invalid use of incomplete type 'struct std::type_info'
<built-in>:0: error: forward declaration of 'struct std::type_info'
abi/cpp/include/cxxabi.h:65: error: invalid use of incomplete type 'struct std::type_info'
<built-in>:0: error: forward declaration of 'struct std::type_info'
abi/cpp/include/cxxabi.h:72: error: invalid use of incomplete type 'struct std::type_info'
<built-in>:0: error: forward declaration of 'struct std::type_info'
解决:
4.0比2.3根目录下多了abi目录,里面只有几个文件,type_info在该目录下typeinfo文件中定义了,
cxxabi.h也包含了这个文件,但不知道为什么报错,在cxxabi.h中添加class type_info 也不行,
后来把typeinfo文件和cxxabi.h中的定义都抽出,定义到一个common.h文件中,两个文件都包含这个文件,暂时规避了这个问题。


14、
ake:进入目录'/home/lijj/android/android-4.0.1'
target thumb C++: binderAddInts <= system/extras/tests/binder/benchmarks/binderAddInts.cpp
system/extras/tests/binder/benchmarks/binderAddInts.cpp:96: error: ISO C++ forbids declaration of 'cpu_set_t' with no type
system/extras/tests/binder/benchmarks/binderAddInts.cpp:96: error: expected ',' or '...' before '&' token
system/extras/tests/binder/benchmarks/binderAddInts.cpp: In function 'int main(int, char**)':
解决:
在binderAddInts.cpp文件开头添加
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
并包含头文件#include <sched.h>


15、
prebuilt/linux-x86/toolchain/arm-eabi-4.4.0_hisi/bin/arm-eabi-gcc -mthumb-interwork -Ibionic/libc/private -DCRT_LEGACY_WORKAROUND -Ibionic/libc/private -o out/target/product/generic/obj/lib/crtbegin_so.o -c bionic/libc/arch-arm/bionic/crtbegin_so.S
prebuilt/linux-x86/toolchain/arm-eabi-4.4.0_hisi/bin/arm-eabi-gcc -mthumb-interwork -Ibionic/libc/private -DCRT_LEGACY_WORKAROUND -Ibionic/libc/private -o out/target/product/generic/obj/lib/crtend_so.o -c bionic/libc/arch-arm/bionic/crtend_so.S
target SharedLib: libdl (out/target/product/generic/obj/SHARED_LIBRARIES/libdl_intermediates/LINKED/libdl.so)
/home/lijj/android/android-4.0.1/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0_hisi/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: unrecognized option '--icf=safe'
/home/lijj/android/android-4.0.1/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0_hisi/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
解决:
修改TARGET_linux-arm.mk中P134行对TARGET_GLOBAL_LDFLAGS的赋值,去掉--icf=safe


16、
In file included from frameworks/base/media/libstagefright/AACWriter.cpp:21:
frameworks/base/include/media/stagefright/AACWriter.h:70: error: ISO C++ forbids declaration of 'DISALLOW_EVIL_CONSTRUCTORS' with no type
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libstagefright_intermediates/AACWriter.o] 错误 1
解决:
添加包含头文件#include <media/stagefright/foundation/ABase.h>


17、
In file included from frameworks/base/media/libstagefright/SurfaceMediaSource.cpp:19:
frameworks/base/include/media/stagefright/SurfaceMediaSource.h:363: error: ISO C++ forbids declaration of 'DISALLOW_IMPLICIT_CONSTRUCTORS' with no type
frameworks/base/include/media/stagefright/SurfaceMediaSource.h: In member function 'virtual android::status_t android::SurfaceMediaSource::setScalingMode(int)':
frameworks/base/include/media/stagefright/SurfaceMediaSource.h:114: error: no return statement in function returning non-void
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libstagefright_intermediates/SurfaceMediaSource.o] 错误 1
make: *** 正在等待未完成的任务....
解决:
将DISALLOW_IMPLICIT_CONSTRUCTORS 改为SurfaceMediaSource( );
这个宏的作用好像就是定义构造函数,在frameworks目录下没有找到该宏的定义,且只看到这一个地方用到了这个宏
external目录有这个宏的定义


18、
In file included from frameworks/base/media/libstagefright/SurfaceMediaSource.cpp:19:
frameworks/base/include/media/stagefright/SurfaceMediaSource.h: In member function 'virtual android::status_t android::SurfaceMediaSource::setScalingMode(int)':
frameworks/base/include/media/stagefright/SurfaceMediaSource.h:114: error: no return statement in function returning non-void
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libstagefright_intermediates/SurfaceMediaSource.o] 错误 1
make: *** 正在等待未完成的任务....
解决:
setScalingMode函数添加return OK;


19、
external/ipsec-tools/src/racoon/isakmp.c: In function 'isakmp_handler':
external/ipsec-tools/src/racoon/isakmp.c:214: error: field 'ip' has incomplete type
external/ipsec-tools/src/racoon/isakmp.c:230: warning: pointer targets in passing argument 6 of 'recvfromto' differ in signedness
external/ipsec-tools/src/racoon/sockmisc.h:68: note: expected 'socklen_t *' but argument is of type 'unsigned int *'
解决:
参照2.3里面在isakmp.c前面 添加
#ifdef ANDROID_CHANGES
#define __linux
#endif
这个文件2.3和4.0里面有了蛮多变化,不知道这么改会不会有问题


20、
target arm C: libwebrtc_aecm <= external/webrtc/src/modules/audio_processing/aecm/main/source/aecm_core.c
/tmp/ccyInhhH.s: Assembler messages:
/tmp/ccyInhhH.s:3864: Error: co-processor offset out of range
/tmp/ccyInhhH.s:3865: Error: co-processor offset out of range
解决:
对比2.3,修改TARGET_linux-arm.mk相关编译选项




21、
/home/lijj/android/android-4.0.1/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0_hisi/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: unrecognized option '--icf=none'
/home/lijj/android/android-4.0.1/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0_hisi/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libdynamic_annotations_intermediates/LINKED/libdynamic_annotations.so] 错误 1
make: *** 正在等待未完成的任务....
解决:
以下几个文件去掉--icf=none
/external/valgrind/dynamic_annotations/Android.mk:27:  LOCAL_LDFLAGS += -Wl,--icf=none 
./external/valgrind/tsan/Android.mk:49:  preload_ldflags += -Wl,--icf=none
./external/valgrind/main/Android.mk:52:  preload_ldflags += -Wl,--icf=none


22、
frameworks/base/native/include/android/native_window.h:36: error: redefinition of typedef 'ANativeWindow'
system/core/include/system/window.h:429: note: previous declaration of 'ANativeWindow' was here
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libEGL_VIVANTE_intermediates/driver/openGL/egl/os/gc_egl_linux.o] 错误 1
make: *** 正在等待未完成的任务....
解决:
android_natives.h中包含了两个头文件
#include <system/window.h>
#include <android/native_window.h>

这两个头文件中都定义了ANativeWindow 去掉了下面个头文件


你可能感兴趣的:(java,android,struct,function,reference,returning)