Sunday 8 November 2015

Installing C++ Boost libraries on MacOS X

This post describes installing Boost on iMac.

Current OS version is 10.11.1.
Current Xcode version is 7.1 (7B91b)

I already have Apple´s SDK Xcode installed. It is free and can be downloaded from App Store. To use it we have to read and accept their license terms, otherwise the bootstrap'ing fails later.

$ sudo xcodebuild -license

I wanted to install the include-files and libraries of boost to /usr/local. 

These are the steps I went through:


Download and unpack Boost from www.boost.org. Current release is Version 1.59.0. I moved the download file boost_1_59_0.tar.bz2 to a directory under my home directory /Users/robert. I will refer to it as /path/to/boost. I decided not to store the whole installation under /usr/local.

$ cd /path/to/boost
$ tar --bzip2 -xf ./boost_1_59_0.tar

To generate the build script issue the commands.

$ cd boost_1_59_0
$ ./bootstrap.sh --prefix=/usr/local


If the toolset darwin is not automatically detected, it may be due to lack of Xcode installation.
If successful you can now build the boost libraries using

$ ./b2 stage

I get a lot of compiler warnings about BOOST_DO_JOIN etc., but no errors at this time. This will build the libraries into subdirectory stage. If successful you can issue the following command to install into /usr/local which was specified using the --prefix option. Use sudo to allow for writing to /usr/local.

$ sudo ./b2 install


No comments: