【Linux】centos8安装bison3.8

centos8安装bison3.8的教程,感觉这个软件很小众啊,百度找不到安装教程,最终还是在起脚旮旯里面翻出来了很久之前的文档,好在没有过时;

虽然centos8中你可以使用yum直接安装,但是哪个安装的版本太低了,达不到如今的需求

yum install bison

我这边直接用yum安装的是3.0.4的版本,已经是2015年的东西了,最新的版本已经到3.8了;

bison (GNU Bison) 3.0.4
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

先用yum把安装好了的删掉

yum remove bison

去官网 http://ftp.gnu.org/gnu/bison/ 下载最新的压缩包

wget http://ftp.gnu.org/gnu/bison/bison-3.8.tar.gz

解压并进入文件夹

tar -zxvf bison-3.8.tar.gz
cd bison-3.8

配置安装路径,这里我使用了/usr/local这个目录,如果你查看过安装后的bison,你会发现它的安装包的逻辑是和/usr/local目录一致的,当然你也可以修改成你自己想要的目录

# ls /usr/local/
bin  doc  etc  games  include  lib  lib64  libexec  openssl-1.1.1  sbin  share  src

使用如下命令配置安装路径为/usr/local

./configure -prefix=/usr/local/

目录配置好了之后,make安装

make install

安装好了之后执行bison --version,你会得到如下输出

-bash: /usr/bin/bison: No such file or directory

这是因为我们在/usr/local里面安装的东西没有在path中,没有办法直接执行,需要我们将其软链接到/usr/bin里面;

如果你的安装正确了,应该可以在/usr/local/bin里面找到bison; 如果你安装的路径不同,那就去你安装路径下找bison的可执行文件;

# ls /usr/local/bin
2to3-3.10  bison  cmake  cpack  ctest  docker-compose  idle3.10  pip3.10  pydoc3.10  python3.10  python3.10-config  yacc

将其软连接一下就ok了

# ln -s /usr/local/bin/bison /usr/bin/bison
# ls /usr/bin/bison
/usr/bin/bison

再次检查版本,安装3.8成功

# bison --version
bison (GNU Bison) 3.8
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

你可能感兴趣的:(玩上Linux,linux)