48

I'm trying to install Thrift on my macbook. Otherwise I got an error:

configure: error: Bison version 2.5 or higher must be installed on the system!

So tried to install Bison on my OS, but I didn't find tutorial on internet. Does anyone who can tell me how to install Bison on my system ?

Kind Regards

S7_0
  • 1,165
  • 3
  • 19
  • 32

5 Answers5

93

See here. You can install with brew:

brew install bison

Then update your scripts or your shell config to use brew's bison first in
your PATH:

export PATH="$(brew --prefix bison)/bin:$PATH"

Or

export PATH="/usr/local/opt/bison/bin:$PATH"
GabLeRoux
  • 16,715
  • 16
  • 63
  • 81
user372895986472
  • 1,084
  • 7
  • 4
14

I needed to set export PATH="/usr/local/opt/bison/bin:$PATH" brew install bison installs the bison new version at /usr/local/Cellar but this path is not set in the $PATH

Harley
  • 564
  • 5
  • 8
13

To save a ton of time use either Macports or Homebrew. These will install all dependent packages for you.

I use Macports, and after installing it, it's as simple as:

$ sudo port install thrift

and it will be done before your coffee is ready.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
  • I wrote "sudo port install thrift" on my terminal, but there was an error "Error: Port thrift not found Can we find a solution ?" Kind Regards. – S7_0 Aug 04 '15 at 09:58
  • @bonzaitek Strange as that port is [available](https://trac.macports.org/browser/trunk/dports/devel/thrift/Portfile). Did you follow all the Macports installation steps (i.e. `sudo port selfupdate`)? – trojanfoe Aug 04 '15 at 10:01
  • Oops... No I didn't, the only handling I did is install from source like " $ curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.3.3.tar.bz2 $ tar xf MacPorts-2.3.3.tar.bz2 $ cd MacPorts-2.3.3/ " In your opinion, this link tutorial is it correct for the rest of the installation ? https://guide.macports.org/chunked/installing.shell.html Kind Regards – S7_0 Aug 04 '15 at 10:08
  • You only need to install like that if you're running El Capitan as it's not officially supported. If you are running non-beta OSX, then there is binary installer available. – trojanfoe Aug 04 '15 at 10:08
  • @NeeleshSalian Yeah I mentioned Homebrew in my answer. – trojanfoe Apr 24 '19 at 06:31
5

I got a warning after brew install bison and when trying brew link bison --force

bison is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of bison.

If you need to have bison first in your PATH run:
  echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile

For compilers to find bison you may need to set:
  export LDFLAGS="-L/usr/local/opt/bison/lib"

So I suggest you to add these two above flags, instead of forcing the link of /usr/local.

So, above all, you will need below three steps:

brew install bison
echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
export LDFLAGS="-L/usr/local/opt/bison/lib"
cinqS
  • 1,175
  • 4
  • 12
  • 32
2

rename the default bison under dir: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin$'

install the newest version of bison by homebrew:

brew install bison

link the bison :

brew link bison --force 

if you need unlink the bison and rename the bison from xcode. best wish ~~

damon-lin
  • 69
  • 4
  • Brew no longer allows force linking system provided packages. Default `bison` shouldn't be renamed. Use `export PATH="$(brew --prefix bison)/bin:$PATH"` when brew's bison is needed in your scripts. – GabLeRoux Dec 21 '20 at 19:00