12

我的 Mac 上的 GNU Bison 版本是 2.3,但我知道 Bison 2.5 是很久以前发布的。Flex & Bison一书使用 2.5 版。

我应该自己升级到 2.5 吗?有必要吗?

2.3和2.5有什么区别?

4

7 回答 7

19

我有同样的问题 MacOSX 10.9.5。

做完之后:

brew install bison

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

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

(当您阅读本文时,您的版本可能与 3.0.4 不同)在我重新启动终端后,它在我重新启动时选择了新版本的 Bisonbison -V

于 2015-09-24T05:30:35.877 回答
18

如果您正在使用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.
于 2019-06-09T08:46:18.590 回答
12

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

$ 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.
于 2015-06-15T11:58:16.183 回答
7

如果您使用 Brew:

brew tap homebrew/dupes && brew install bison

如果您使用 MacPorts:

sudo port install bison

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

如果你知道如何安装 Unix 软件,下载它,解压缩,然后像往常一样配置/制作/安装。

如果以上所有内容对您来说都是希腊语,请查看Linkhttp://macports.org并决定哪个对您更友好。

于 2012-05-30T01:06:54.913 回答
4

所以我想出了如何摆脱 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 -V
bison (GNU Bison) 3.7.1

在运行 Mojave 的多个 macOS 系统上构建 wine 时遇到了很多问题。主要是由于对我从未听说过的库的这种奇怪需求,但这个修复让它工作了。

于 2020-08-10T04:36:37.207 回答
0

我使用了 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.
于 2015-02-02T18:28:49.567 回答
0

因为安装了bison,所以osx上的默认版本是2.3。所以我们应该做如下事情:

  1. 安装更高版本的os bison

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

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

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

    $ which bison --- 找到安装的路径,在我的电脑里是 /usr/bin/bison

    $ cd /usr/bin

    $ sudo mv 野牛 bison.2.3

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

然后你可以安装 thrift 而不会出现这个问题。

于 2016-01-26T16:19:26.123 回答