S7_0
S7_0

Reputation: 1183

How to install bison on mac OSX

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

Upvotes: 48

Views: 70279

Answers (5)

user372895986472
user372895986472

Reputation: 1112

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"

Upvotes: 95

Harley
Harley

Reputation: 562

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

Upvotes: 14

cinqS
cinqS

Reputation: 1223

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"

Upvotes: 5

damon-lin
damon-lin

Reputation: 69

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 ~~

Upvotes: 2

trojanfoe
trojanfoe

Reputation: 122421

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.

Upvotes: 13

Related Questions