更改make/bison的版本

时间:2022-09-11 03:29:24

一.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
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.4
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-4.7

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

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  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"
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_45/bin/javac"
update-alternatives --install "/usr/bin/javadoc" "javadoc" "/usr/lib/jvm/jdk1.6.0_45/bin/javadoc"
update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.6.0_45/jre/lib/amd64/libnpjp2.so"
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_45/bin/javaws"
update-alternatives --install "/usr/bin/javap" "javap" "/usr/lib/jvm/jdk1.6.0_45/bin/javap"
update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.6.0_45/bin/jar"

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不会报该错误

 In file included from plural.y:::
plural-exp.h::: error: conflicting types for 'libintl_gettextparse'
# define PLURAL_PARSE libintl_gettextparse
^
plural.y::: note: in expansion of macro 'PLURAL_PARSE'
# define __gettextparse PLURAL_PARSE
^
plural.c::: note: in expansion of macro '__gettextparse'
int __gettextparse (void);
^
plural-exp.h::: note: previous declaration of 'libintl_gettextparse' was here
# define PLURAL_PARSE libintl_gettextparse
^
plural-exp.h::: note: in expansion of macro 'PLURAL_PARSE'
extern int PLURAL_PARSE (void *arg);
^
plural-exp.h::: error: conflicting types for 'libintl_gettextparse'
# define PLURAL_PARSE libintl_gettextparse
^
plural.y::: note: in expansion of macro 'PLURAL_PARSE'
# define __gettextparse PLURAL_PARSE
^
plural.c::: note: in expansion of macro '__gettextparse'
#define yyparse __gettextparse
^
plural.c::: note: in expansion of macro 'yyparse'
yyparse (void)
^
plural-exp.h::: note: previous declaration of 'libintl_gettextparse' was here
# define PLURAL_PARSE libintl_gettextparse
^
plural-exp.h::: note: in expansion of macro 'PLURAL_PARSE'
extern int PLURAL_PARSE (void *arg);
^
plural.c: In function 'libintl_gettextparse':
plural.c::: error: too few arguments to function '__gettextlex'
yychar = yylex (&yylval);
^
plural.c::: note: declared here
#define yylex __gettextlex
^
plural.y::: note: in expansion of macro 'yylex'
static int yylex (YYSTYPE *lval, const char **pexp);
^
plural.y::: error: 'arg' undeclared (first use in this function)
((struct parse_args *) arg)->res = $;
^
plural.y::: note: each undeclared identifier is reported only once for each function it appears in
Makefile:: recipe for target 'plural.o' failed
make[]: *** [plural.o] Error