Compiling Boost on Mac OS X
Posted in Programming on August 20th, 2009 by Simon Connah – Be the first to commentI often see people asking how to compile the Boost C++ libraries on Mac OS X so I thought I would post a quick tutorial.
- Download B-jam from http://www.boost.org/ – you will find it in the “Downloads” area of the site. Make sure you download the Mac OS X binary file to avoid problems.
- When B-jam has been download, extract the archive by double clicking on it.
- Move the executable entitled “bjam” to a directory on your path. If you don’t know what this means then just open the Terminal application and type “cd ” (the trailing space is very important) then drag the folder which you just extracted onto the Terminal window, click once in the Terminal window and then press return.
- Type “sudo mv bjam /usr/bin” exactly as shown, you will then be asked to type your administrator password. Once you have typed it in press return and bjam will now be accessible from the command line.
- Next download the source code distribution of Boost from http://www.boost.org/ – this is found in the same place as B-jam.
- Extract the archive and then open the folder in Terminal using the same method outlined above.
- Type “bjam stage –build-type=complete” and press return. Wait for a couple of hours for it to finish and then type “sudo make install” to install the boost libraries on your machine.
Update: For those who want to build just the 64 bit versions of the shared library that are thread safe in release mode (this is a much, much faster build time) then you can substitute the build command in stage 7 above with this one:
bjam toolset=darwin link=shared threading=multi runtime-link=shared variant=release address-model=64 stage
Update 2: To build a 32 bit version for PowerPC Macs and a 32 bit and 64 bit version for Intel Macs in a universal binary you need to substitute phase 7 listed above for the following command:
bjam toolset=darwin threading=multi variant=release link=shared runtime-link=shared address-model=32_64 architecture=combined