ubuntu16.04编译android5.1环境配置

时间:2022-12-03 09:19:56

原先想在16.10上编译android5.1的,结果碰到下面的错误

/tmp/BitcodeWrapper-ea75d3.s: Assembler messages:
/tmp/BitcodeWrapper-ea75d3.s:12876: Error: inconsistent uses of .cfi_sections
Clang ++: error: assembler command failed with exit code 1 (use -v to see invocation)

经过长时间搜索之后发现问题出在binutils上,16.10的binutils版本是2.27,太高了导致不兼容,如果回退到2.26就没有这个问题了,但是回退的话可能在系统上导致其他的问题,因此我就选择在16.04上编译android5.1了,16.04的binutils版本是2.26,如果有能解决这个问题的希望可以告知我

安装openjdk7

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-7-jdk
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
sudo java -version

安装ubuntu 16的依赖

sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386 \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib \
tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 \
dpkg-dev libsdl1.2-dev libesd0-dev \
git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev gcc-multilib g++-multilib \
libc6-dev-i386 \
lib32ncurses5-dev x11proto-core-dev libx11-dev \
lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc unzip m4

如果提示 “mkimage” command not found – U-Boot images will not be built
使用下面命令安装

sudo apt-get install u-boot-tools

提示clang: error: linker command failed with exit code

cd  <source_android>/art/build/
vim Android.common_build.mk
修改前:
# Host.
ART_HOST_CLANG := false
ifneq ($(WITHOUT_HOST_CLANG),true)
# By default, host builds use clang for better warnings.
ART_HOST_CLANG := true
endif
修改后:
# Host.
ART_HOST_CLANG := false
ifneq ($(WITHOUT_HOST_CLANG),false)
# By default, host builds use clang for better warnings.
ART_HOST_CLANG := true
endif

提示error: unsupported reloc 43的话使用下面命令

cp /usr/bin/ld.gold <source_android>/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/ld

然后执行一次make update-api,再make

参考:
http://blog.csdn.net/fuchaosz/article/details/51487585
http://blog.csdn.net/u014770862/article/details/52624851
https://w3bsit3-dns.com/forum/index.php?showtopic=209610&st=17880