第一步:下载以及安装jdk 1.7.x
由于之前就已经下载好了java-7-openjdk-amd64.tar,因此在这里只需要复制到/opt/jdk目录下,一般来说jdk目录是自己创建的。
mkdir jdk
解压java-7-openjdk-amd64.tar
sudo tar -vxf java-7-openjdk-amd64.tar
打开~/.bashrc ,配置jdk环境,添加如下
export JAVA_HOME = /opt/jdk/java-7-openjdk-amd64
export ANDROID_JAVA_HOME=$JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
第二步:安装编译依赖库
apt-get install -y git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
g++-multilib mingw32 tofrodos libgl1-mesa-dev \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386
安装过程中出现错误:E.无法定位安装包mingw32
解决方法:
打开下载源文件sources.list
sudo vim /etc/apt/sources.list
在sources.list末尾添加语句并保存退出
deb http://us.archive.ubuntu.com/ubuntu trusty main universe
再次更新安装便可
sudo apt-get update
sudo apt-get install mingw32
第三步:查看一些编译版本是否满足
Perl >=5.18.4
Python >=2.7.6
GNU make >=3.18
GNU gcc >=4.8.4
(1)查看Perl版本
linux@linux-PC:/opt$ perl -version
This is perl 5, version 24, subversion 1 (v5.24.1) built for x86_64-linux-gnu-thread-multi
(with 85 registered patches, see perl -V for more detail)
(2)查看python版本
linux@linux-PC:/opt$ python -V
Python 2.7.13
(3)查看gnu make版本
linux@linux-PC:/opt$ make -v
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(4)查看gcc版本
linux@linux-PC:/media/gentle/_dde_data/codes/ac8257$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18+deb9u1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posi
gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
第四步,执行编译
source ./build/envsetup.sh
lunch xxx_platform
./allmake.sh
如果出现如下错误
./allmake.sh: 26: ./allmake.sh: Syntax error: "(" unexpected
执行命令
sudo dpkg-reconfigure dash
弹出界面,选择否便可,这是因为debian为了加快执行速度,把bash改为dash,我们通过命令恢复为bash
第一种错误:
error:flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed. Aborted (core dumped)
或者FAILED: out/host/linux-x86/obj/EXECUTABLES/checkpolicy_intermediates/policy_scan.c
/bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/EXECUTABLES/checkpolicy_intermediates/policy_scan.c external/selinux/checkpolicy/policy_scan.l"
flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.
Aborted (core dumped)
解决方法: 使用命令:(相关解说https://blog.csdn.net/weixin_33941350/article/details/93094299)
export LC_ALL=C
第二种错误:
**make: *** No rule to make target 'out/target/product/evb3561sv_w_no2/obj_arm/STATIC_LIBRARIES/libcam.halmemory_intermediates/export_includes', needed by 'out/target/product/evb3561sv_w_no2/obj_arm/SHARED_LIBRARIES/libcam_platform_intermediates/import_includes'. Stop.
make: *** Waiting for unfinished jobs....**
解决方法: 网上查看是说cmake太高了,因此降级为3.81尝试一下.最终不报这种错误了。
https://www.jianshu.com/p/1d3321ad36a2(中间遇到的问题,就是make出错解决方法
wget http://ftp.gnu.org/gnu/make/make-3.81.tar.gz
tar xf make-3.81.tar.gz
cd make-3.81
./configure --prefix=/usr/local/make-3.81
sh build.sh
sudo cp make /usr/bin/make
第三种错误:error: unsupported reloc 42
解决方法: 这种错误几乎都是修改源码的一些方法,但是按照仅仅的编译来说,应该尽量不要修改源码,因此我写了一个脚本,每次编译前把ld链接到本地,编译完后再用git checkout复原。脚本内容如下:
#备份以及全局链接函数
function change_ld_glod
{
echo "ROOT_PATH=$ROOT_PATH"
mv $ROOT_PATH/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin/ld $ROOT_PATH/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin/ld.bak
ln -s /usr/bin/ld.gold $ROOT_PATH/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin/ld
}
#恢复函数
function recovery_ld_glod
{
echo "recovery /usr/bin/ld.gold"
mv $ROOT_PATH/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin/ld.bak $ROOT_PATH/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin/ld
}
#编译之前全局链接
change_ld_glod
source ./build/envsetup.sh
lunch xxx_platform
./allmake.sh
#编译完成后恢复
recovery_ld_glod