211

How do you install Boost on MacOS? Right now I can't find bjam for the Mac.

MrTux
  • 32,350
  • 30
  • 109
  • 146
Robert Gould
  • 68,773
  • 61
  • 187
  • 272

11 Answers11

335

You can get the latest version of Boost by using Homebrew.

brew install boost.

Ky -
  • 30,724
  • 51
  • 192
  • 308
jrwren
  • 17,465
  • 8
  • 35
  • 56
163

Download MacPorts, and run the following command:

sudo port install boost 
Honest Abe
  • 8,430
  • 4
  • 49
  • 64
dies
  • 1,694
  • 1
  • 11
  • 2
121

Just get the source, and compile Boost yourself; it has become very easy. Here is an example for the current version of Boost on the current macOS as of this writing:

  1. Download the the .tar.gz from https://www.boost.org/users/download/#live
  2. Unpack and go into the directory:

    tar -xzf boost_1_50_0.tar.gz
    cd boost_1_50_0
  3. Configure (and build bjam):

    ./bootstrap.sh --prefix=/some/dir/you/would/like/to/prefix
  4. Build:

    ./b2
  5. Install:

    ./b2 install

Depending on the prefix you choose in Step 3, you might need to sudo Step 5, if the script tries copy files to a protected location.

MCCCS
  • 1,002
  • 3
  • 20
  • 44
snies
  • 3,461
  • 1
  • 22
  • 19
  • 4
    Best route if you need to link against boost_thread. The standard brew recipes don't seem to include it. – Wedge Martin May 27 '14 at 14:52
  • If you want to install other executables that depends on boost at default runtime environment ok, use other answers, in any other case, use this answer. Best for you to know when you ara compiling with boost and how. You will have it as as it is supposed to be. And Most important, It will force you to think where boost will be on Continuous Integration (Build) server, and if has an deployment server too. – wdavilaneto Jan 05 '15 at 05:16
  • 1
    Can you please explain step 3? @snies – MAS Oct 22 '15 at 13:40
  • 1
    @MAS (I did not try it today. But the bootstrap.sh should come with the tar.gz file. It configures the build process and creates the bjam build tool. The "prefix" is a common option for build tools which will be prefixed to the install path. This means, that if a file would be installed in /bin it will instead be installed in /prefix/bin when the install command is issued. You can use that to avoid permission problems. For example i install optional packages i use for development in /home/snies/opt/bin instead of /bin so i don't need root permissions and don't mess up my system. – snies Oct 23 '15 at 08:20
7

Install both of them using homebrew separately.

brew install boost
brew install bjam

Kondal Rao
  • 151
  • 1
  • 6
6

Unless your compiler is different than the one supplied with the Mac XCode Dev tools, just follow the instructions in section 5.1 of Getting Started Guide for Unix Variants. The configuration and building of the latest source couldn't be easier, and it took all about about 1 minute to configure and 10 minutes to compile.

Daniel James
  • 3,899
  • 22
  • 30
5

Fink appears to have a full set of Boost packages...

With fink installed and running just do

fink install boost1.35.nopython

at the terminal and accept the dependencies it insists on. Or use

fink list boost

to get a list of different packages that are availible.

dmckee --- ex-moderator kitten
  • 98,632
  • 24
  • 142
  • 234
5

Install Xcode from the mac app store. Then use the command:

  /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

the above will install homebrew and allow you to use brew in terminal

then just use command :

brew install boost

which would then install the boost libraries to <your macusername>/usr/local/Cellar/boost

UDAY JAIN
  • 51
  • 1
  • 4
4

In order to avoid troubles compiling third party libraries that need boost installed in your system, run this:

sudo port install boost +universal
user1823890
  • 704
  • 8
  • 7
4

Try +universal

One thing to note: in order for that to make a difference you need to have built python with +universal, if you haven't or you're not sure you can just rebuild python +universal. This applies to both brew as well as macports.

$ brew reinstall python
$ brew install boost

OR

$ sudo port -f uninstall python
$ sudo port install python +universal
$ sudo port install boost +universal
Community
  • 1
  • 1
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
3

you can download bjam for OSX (or any other OS) here

Ferruccio
  • 98,941
  • 38
  • 226
  • 299
2

If you are too lazy like me: conda install -c conda-forge boost

Neo li
  • 378
  • 3
  • 8