Android 源码编译及常见错误及解决方法

最近要往arm开发板上移植android系统,大大小小的问题遇到了太多太多,都是泪啊。本人初接触嵌入式开发,对问题的根源不是太了解,不过好在每解决一个问题,便记录一下。话不多说,正式罗列问题:

 host Executable: a3dconvert (out/host/linux-x86/obj/EXECUTABLES/a3dconvert_intermediates/a3dconvert)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5./libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5./libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5./libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5./libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: ld returned exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/a3dconvert_intermediates/a3dconvert] Error
解决方法:
缺少g++-multilib库,安装即可: apt-get install g++-multilib
$ sudo apt-get install g++-multilib g++-4.5-multilib
 g++: 错误: –fpermissive:没有那个文件或目录
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误
解决方法:
sudo apt-get install g++-4.4-multilib
 rameworks/base/libs/utils/RefBase.cpp: 在成员函数‘void android::RefBase::weakref_type::trackMe(bool, bool)’中:
frameworks/base/libs/utils/RefBase.cpp::: 错误: 将‘const android::RefBase::weakref_impl’作为‘void android::RefBase::weakref_impl::trackMe(bool, bool)’的‘this’实参时丢弃了类型限定 [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误
原因:
Ubuntu 11.10的gcc 4.6版本太高了,android编译需要gcc 4.4
解决方法:
更换gcc、g++版本4.6为4.4
sudo apt-get install gcc-4.4
sudo apt-get install g++-4.4
sudo rm -rf /usr/bin/gcc /usr/bin/g++
sudo ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.4 /usr/bin/g++
 /usr/bin/ld: cannot find -lz
host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: cannot find -lz
collect2: ld returned exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error
解决方法:
sudo apt-get install zlib1g-dev
sudo apt-get install lib64z1-dev
 /bin/bash: bison: command not found
Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y
bison -d -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
/bin/bash: bison: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error
解决方法:
sudo apt-get install bison
 /bin/bash: flex: command not found
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp: In function ‘int yyparse()’:
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:: warning: deprecated conversion from string constant to ‘char*’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:: warning: deprecated conversion from string constant to ‘char*’
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
/bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error
解决方法: 
sudo apt-get install flex
 /usr/bin/ld: cannot find -lncurses
host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
/usr/bin/ld: cannot find -lncurses
collect2: ld returned exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error
解决方法:
sudo apt-get install libncurses5-dev
 fatal error: GL/glx.h: No such file or directory
development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:: fatal error: GL/glx.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error
解决方法:
sudo apt-get install libgl1-mesa-dev
 sh: gperf: not found
target Generated: libwebcore <= external/webkit/Source/JavaScriptCore/create_regex_tables
Generating CSSPropertyNames.h <= CSSPropertyNames.in
sh: gperf: not found
calling gperf failed: at ./makeprop.pl line .
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] Error
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h'
解决方法:
sudo apt-get install gperf
 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::: 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] 错误
解决方法:
gedit frameworks/base/libs/utils/Android.mk
将语句:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
修改为:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive
 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:: 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:: undefined reference to `pthread_key_create'
/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:: undefined reference to `pthread_setspecific'
collect2: ld returned exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize] 错误
解决方法:
修改./framework/base/tools/localize/Android.mk文件
ifeq ($(HOST_OS),linux)
#LOCAL_LDLIBS += -lrt       把这行注释掉,改为下面一行。
LOCAL_LDLIBS += -lrt -lpthread
endif
上一篇:python爬取网站数据


下一篇:Ubuntu编译Android源码过程中的空间不足解决方法