Ubuntu12.04LTS 编译android 错误总结
host SharedLib: libfst (out/host/linux-x86/obj/lib/libfst.so) host StaticLib: libtinyxml (out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/libtinyxml.a) echo out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxml.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxmlparser.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxmlerror.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinystr.o | xargs ar crsP out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/libtinyxml.a host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb) /true usr/bin/ld: cannot find -lncurses collect2: ld 返回 1 make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] 错误 1
把遇到的错误都记录下来,方便后人。
编译时出现/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.so when searching for -lz错误============================================
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=AOSP
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv5te
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
============================================
host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.a when searching for -lz
/usr/bin/ld: skipping incompatible //usr/lib/libz.so when searching for -lz
/usr/bin/ld: skipping incompatible //usr/lib/libz.a when searching for -lz
/usr/bin/ld: cannot find -lz
apt-get install lib32z1-dev
2.
Install: out/host/linux-x86/bin/traceview
host Executable: unpackbootimg (out/host/linux-x86/obj/EXECUTABLES/unpackbootimg_intermediates/unpackbootimg)
/usr/bin/ld: cannot find -lncurses
collect2: ld 返回 1
make: *** [out/host/linux-x86/obj/EXECUTABLES/sqlite3_intermediates/sqlite3] 错误 1
make: *** 正在等待未完成的任务....
true
true
3
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>: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
此处编译错误是由于ubuntu 11.10采用了GCC4.6.1导致的。
解决方法:
修改源码目录下/build/core/combo/HOST_linux-x86.mk文件:
将以下语句
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
修改为
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
4
host SharedLib: libfst (out/host/linux-x86/obj/lib/libfst.so) host StaticLib: libtinyxml (out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/libtinyxml.a) echo out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxml.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxmlparser.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinyxmlerror.o out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/tinystr.o | xargs ar crsP out/host/linux-x86/obj/STATIC_LIBRARIES/libtinyxml_intermediates/libtinyxml.a host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb) /true usr/bin/ld: cannot find -lncurses collect2: ld 返回 1 make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] 错误 1
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
解决:
sudo apt-get install lib32ncurses5-dev