更改Android编译软件版本(make/gcc/bision)

一.make版本

1.下载make的压缩包

ftp://ftp.gnu.org/gnu/make/

2.解压,安装

cd make-x.x
./configuration
sh build.sh
sudo make install

3.查看版本信息

make -v

二.gcc版本

1.使用命令安装gcc,以gcc-4.7为例,具体版本请自行决定

sudo apt-get install gcc-4.7 g++-4.7 g++-4.7-multilib gcc-4.7-multilib

 2.若出现无法定位软件包,请添加源,并更新源

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update

3.切换gcc版本,如从gcc4.7切换到gcc4.4

update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 100
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.7 50
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 100
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 50
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.4 100
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.7 50

  也可以使用如下命令,根据需求去选择

sudo update-alternatives --config gcc
sudo update-alternatives --config g++
sudo update-alternatives --config cpp

 4.查看版本信息

gcc -v
g++ -v

三.jdk版本

说明:Android4.x之前请使用jdk1.6,Android5.x请使用openjdk7

1.安装jdk,以jdk1.6.0_45为例

  1.1 到官网选择具体的jdk版本下载:

    http://www.oracle.com/technetwork/java/javase/archive-139210.html

  1.2 复制到/usr/lib/jvm下

sudo cp jdk-6u45-linux-x64.bin /usr/lib/jvm

  1.3 增加可执行权限

sudo chmod 777 jdk-6u45-linux-x64.bin

  1.4 解压

sudo ./jdk-6u45-linux-x64.bin

  1.5 配置环境变量

sudo gedit /etc/environment

    在最后添加如下信息,保存退出

export PATH=/usr/lib/jvm/jdk1.6.0_45/bin:$PATH

    使用如下命令使环境变量生效

source /etc/environment

2.配置jdk,其中Android4.0不需要配置javap,而Android4.4以上版本需要配置

update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_45/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_45/bin/javac" 1
update-alternatives --install "/usr/bin/javadoc" "javadoc" "/usr/lib/jvm/jdk1.6.0_45/bin/javadoc" 1
update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.6.0_45/jre/lib/amd64/libnpjp2.so" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_45/bin/javaws" 1
update-alternatives --install "/usr/bin/javap" "javap" "/usr/lib/jvm/jdk1.6.0_45/bin/javap" 1
update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.6.0_45/bin/jar" 1

3.更新jdk配置

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javadoc
sudo update-alternatives --config mozilla-javaplugin.so
sudo update-alternatives --config javaws
sudo update-alternatives --config javap
sudo update-alternatives --config jar

 4.查看版本信息

java -version
javac -version

四.bison版本

1.下载bison的压缩包

http://ftp.gnu.org/gnu/bison/

2.解压,安装

cd bison-x.x
./configure
make
sudo make install

   Bison版本不对,可能会引发如下错误(以下错误基于Bison3.0.4与Bison3.0.2,Bison2.7.1不会报该错误

 1 In file included from plural.y:35:0:
 2 plural-exp.h:94:23: error: conflicting types for 'libintl_gettextparse'
 3  # define PLURAL_PARSE libintl_gettextparse
 4                        ^
 5 plural.y:40:25: note: in expansion of macro 'PLURAL_PARSE'
 6  # define __gettextparse PLURAL_PARSE
 7                          ^
 8 plural.c:187:5: note: in expansion of macro '__gettextparse'
 9  int __gettextparse (void);
10      ^
11 plural-exp.h:94:23: note: previous declaration of 'libintl_gettextparse' was here
12  # define PLURAL_PARSE libintl_gettextparse
13                        ^
14 plural-exp.h:106:12: note: in expansion of macro 'PLURAL_PARSE'
15  extern int PLURAL_PARSE (void *arg);
16             ^
17 plural-exp.h:94:23: error: conflicting types for 'libintl_gettextparse'
18  # define PLURAL_PARSE libintl_gettextparse
19                        ^
20 plural.y:40:25: note: in expansion of macro 'PLURAL_PARSE'
21  # define __gettextparse PLURAL_PARSE
22                          ^
23 plural.c:63:25: note: in expansion of macro '__gettextparse'
24  #define yyparse         __gettextparse
25                          ^
26 plural.c:1108:1: note: in expansion of macro 'yyparse'
27  yyparse (void)
28  ^
29 plural-exp.h:94:23: note: previous declaration of 'libintl_gettextparse' was here
30  # define PLURAL_PARSE libintl_gettextparse
31                        ^
32 plural-exp.h:106:12: note: in expansion of macro 'PLURAL_PARSE'
33  extern int PLURAL_PARSE (void *arg);
34             ^
35 plural.c: In function 'libintl_gettextparse':
36 plural.c:1277:7: error: too few arguments to function '__gettextlex'
37        yychar = yylex (&yylval);
38        ^
39 plural.c:64:25: note: declared here
40  #define yylex           __gettextlex
41                          ^
42 plural.y:57:12: note: in expansion of macro 'yylex'
43  static int yylex (YYSTYPE *lval, const char **pexp);
44             ^
45 plural.y:154:29: error: 'arg' undeclared (first use in this function)
46       ((struct parse_args *) arg)->res = $1;
47                              ^
48 plural.y:154:29: note: each undeclared identifier is reported only once for each function it appears in
49 Makefile:192: recipe for target 'plural.o' failed
50 make[3]: *** [plural.o] Error 1

 

posted @ 2016-10-31 10:11  某某璀  阅读(2902)  评论(0编辑  收藏  举报
levels of contents