How to install bison on mac OSX
Asked Answered
P

5

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

Physiologist answered 4/8, 2015 at 9:23 Comment(0)
B
94

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"
Brahmanism answered 2/2, 2016 at 19:9 Comment(5)
When would it be necessary to unlink bison? I am sure to forget.Shifra
Why do we need to link and unlink? When should we unlink it again after linking?Uniformitarian
Brew no longer allows force linking system provided packages. Use export PATH="$(brew --prefix bison)/bin:$PATH" when brew's bison is needed in your scripts.Methyl
I updated this answer to reflect that my previous comment.Methyl
sometimes you might need bsion2.7, so brew install [email protected] then export PATH="$(brew --prefix [email protected])/bin:$PATH" to your configThomajan
Z
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

Zelma answered 11/6, 2019 at 12:54 Comment(1)
Thanks for this suggestion. I have the same issue on macOS 10.15.2Pelican
T
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.

Tabulator answered 4/8, 2015 at 9:32 Comment(5)
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.Physiologist
@bonzaitek Strange as that port is available. Did you follow all the Macports installation steps (i.e. sudo port selfupdate)?Tabulator
Oops... No I didn't, the only handling I did is install from source like " $ curl -O 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 ? guide.macports.org/chunked/installing.shell.html Kind RegardsPhysiologist
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.Tabulator
@NeeleshSalian Yeah I mentioned Homebrew in my answer.Tabulator
A
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"
Auroora answered 9/10, 2018 at 6:22 Comment(1)
Don't forget to do "source ~/.bash_profile" for this to work as expected.Censure
E
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 ~~

Effrontery answered 15/3, 2016 at 6:13 Comment(1)
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.Methyl

© 2022 - 2024 — McMap. All rights reserved.