为什么gnu bison在MacOSX 10.7.3上升级到2.5?

时间:2012-05-28 03:01:26

标签: macos gnu bison

我开始在我的Mac上使用GNU bison。 当我使用--version时,我看到野牛是v2.3, 但很久以前野牛得到2.5升级。 本书flex & bison使用2.5版作为工具。 我应该自己升级到2.5吗?有必要吗? 或者2.3和2.5之间有什么区别?

7 个答案:

答案 0 :(得分:8)

如果您使用Brew:

brew tap homebrew/dupes && brew install bison

如果您使用MacPorts:

sudo port install bison

如果你使用Fink,他们仍然使用2.3,就像Apple一样,所以你必须自己编辑包。

如果您知道如何安装Unix软件,请下载,解压缩,然后照常配置/ make / install。

如果以上所有内容都是希腊语,请查看http://mxcl.github.com/homebrew/http://macports.org并确定哪一个看起来更友好。

答案 1 :(得分:8)

您可以使用自制软件安装新版本:

$ brew install bison

...

This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Some formulae require a newer version of bison.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/bison/lib

==> Summary
  /usr/local/Cellar/bison/3.0.4: 51 files, 2.2M, built in 74 seconds

但如果你运行:bison -V,它仍会输出2.3,而不是新安装的3.0.4。要强制执行此操作,您可以运行此命令:

arganzhengs-MacBook-Pro:thrift argan$ brew unlink bison
Unlinking /usr/local/Cellar/bison/3.0.4... 0 symlinks removed
arganzhengs-MacBook-Pro:thrift argan$ brew link bison
Warning: bison is keg-only and must be linked with --force
Note that doing so can interfere with building software.
arganzhengs-MacBook-Pro:thrift argan$ brew link bison --force
Linking /usr/local/Cellar/bison/3.0.4... 9 symlinks created
arganzhengs-MacBook-Pro:thrift argan$ bison -V
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2006 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.
arganzhengs-MacBook-Pro:thrift argan$ source ~/.bash_profile 
arganzhengs-MacBook-Pro:thrift argan$ bison -V
bison (GNU Bison) 3.0.4
Written by Robert Corbett and Richard Stallman.

答案 2 :(得分:7)

我有同样的问题MacOSX 10.9.5。

完成后:

brew install bison

我将此添加到我的bash个人资料中:

export PATH=/usr/local/Cellar/bison/3.0.4/bin:$PATH

(当您阅读本文时,您的版本可能与3.0.4不同) 在我重新启动终端后,当我执行bison -V

时,它接收了新版本的Bison

答案 3 :(得分:3)

所以我想出了如何消除Mojave和Catalina上的野牛构建问题。

这就是我所做的:

$ brew install bison
$ cp /usr/local/opt/bison/bin/bison /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison

-

不需要管理员权限,cp命令将覆盖 Xcode应用中的bison二进制文件,其中有自制软件安装的最新版本。

现在我可以这样做:

    $ bison -V
bison (GNU Bison) 3.7.1

在运行Mojave的多个macOS系统上构建Wine时遇到了很多问题。主要是由于对一个我从未听说过的库的怪异需求,但是此修复程序使它可以正常工作。

答案 4 :(得分:1)

我使用Brew并安装了包。但是,这并不会更新野牛的位置。我仍然看到野牛2.3而不是2.5。

然后,我发现新野牛的位置不同。

bash-3.2$ echo $PATH
/opt/local/bin:/opt/local/sbin:/Users/taposh/anaconda/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/m4/bin/
bash-3.2$ PATH=/usr/local/bison/bin/:$PATH
bash-3.2$ which bison
/usr/local/bison/bin//bison

bash-3.2$ bison --version
bison (GNU Bison) 2.5
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2011 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.

答案 5 :(得分:0)

由于已安装bison,因此osx上的默认版本为2.3。所以我们应该采取以下措施:

  1. 安装更高版本的os bison

      

    如果您使用Brew,请尝试使用此命令 - brew install bison,它将安装bison 3.0.2。二进制包在我的计算机上的/usr/local/Cellar/bison/3.0.4/bin/下。

         

    或者您可以通过源代码安装bison,按照官方网站http://www.gnu.org/software/bison/上的说明操作。

  2. 替换旧的(您需要sudo或root权限)

      

    $哪个野牛---找到已安装的路径,在我的电脑中它/ usr / bin / bison

         

    $ cd / usr / bin

         

    $ sudo mv bison bison.2.3

         

    $ sudo cp /usr/local/Cellar/bison/3.0.4/bin/bison bison

  3. 然后你可以安装没有这个问题的节俭。

答案 6 :(得分:0)

如果您使用的是zsh

$ brew unlink bison
$ echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc
$ export LDFLAGS="-L/usr/local/opt/bison/lib"
$ source ~/.zshrc
$ bison -V
bison (GNU Bison) 3.4.1
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2019 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.