Skip to content

Compiling Boost

Joe Holub edited this page Oct 20, 2020 · 6 revisions

Compiling Boost is fairly automated on all platforms. Just pick your operating system and follow the steps and you should be good to go.

Mac OS X

The only prerequisite is that you have gcc or Xcode installed.

Compiling Bjam

  1. First download Boost-1.74.0
  2. Unzip the archive to $BOOST_HOME
  • A good example of $BOOST_HOME is /Users/username/Programming/Libraries/boost-1.52.0-src
  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run ./bootstrap.sh (You may want to run bootstrap with --help the first time to see options like --prefix)

Compiling Static Boost (*.a's) - Preferred Method

  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run "./b2 --stagedir=$INSTALL_HOME variant=release link=static threading=multi runtime-link=shared -j 8"
  • A good example of $INSTALL_HOME is /Users/username/Programming/Libraries/boost-1.52.0
  1. Create a new folder $INSTALL_HOME/include
  2. Copy the $BOOST_HOME/boost folder into the $INSTALL_HOME/include folder

Compiling Shared Boost (*.dylibs)

  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run "./b2 --stagedir=$INSTALL_HOME variant=release link=shared threading=multi runtime-link=shared -j 8"
  • A good example of $INSTALL_HOME is /Users/username/Programming/Libraries/boost-1.52.0
  1. Create a new folder $INSTALL_HOME/include
  2. Copy the $BOOST_HOME/boost folder into the $INSTALL_HOME/include folder

You can use static or shared boost libs, totally up to you. I prefer static libs for boost on Mac OS X. Otherwise you have to deal with settings the DYLD_LIBRARY_PATH all the time in Xcode to properly find the dylibs which is just a pain.

iOS 7

The only prerequisite is that you have Xcode installed.

Compiling Bjam

  1. First download Boost-1.54.0
  2. Unzip the archive to $BOOST_HOME
  • A good example of $BOOST_HOME is /Users/username/Programming/Libraries/boost-1.54.0-src
  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run ./bootstrap.sh

Setting up your user-config.jam file

  1. Create a file called /Users/username/user-config.jam
  2. Open the file with a text editor
  3. Paste the following block in
using clang : ios
     : xcrun clang -arch armv7 -arch armv7s -stdlib=libc++ -std=gnu++11 -miphoneos-version-min=7.0 -mthumb -fvisibility=hidden -fvisibility-inlines-hidden -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/
     ;

Compiling Static Boost (*.a's) - Device

  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run "./b2 --prefix=$INSTALL_HOME variant=release link=static threading=multi runtime-link=shared toolset=clang-ios -j 8 install"
  • A good example of $INSTALL_HOME is /Users/username/Programming/Libraries/boost-1.54.0-device
  • This will build the device version since it uses the arm architecture and iphone version

As a couple side notes, these instructions will not help you build boost to run in the iOS simulator. If you want to do this you're going to have to follow the same process except build against the i386 architecture instead of the arm architecture. Also note that these instructions do not support the new x64 architecture for iOS.

Windows

Compiling Boost is fairly automated. The only prerequisite for these instructions is that you have Visual Studio installed.

Compiling Bjam

  1. First download Boost-1.52.0
  2. Unzip the archive to $BOOST_HOME
  • A good example of $BOOST_HOME is C:\libraries\boost-1.52.0-src
  1. Open up a terminal (run->cmd)
  2. cd to $BOOST_HOME\tools\build\v2
  3. Run bootstrap.bat
  4. Run b2 install --prefix=$PREFIX
  • A good example of $PREFIX is C:\libraries\boost-build-1.52.0
  1. Add $PREFIX\bin to your $PATH environment variable

Compiling Static Boost (*.libs) - Preferred Method

  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run "b2 --stagedir=$INSTALL_HOME toolset=msvc variant=release link=static threading=multi runtime-link=shared -j 8"
  • A good example of $INSTALL_HOME is C:\libraries\boost-1.52.0
  1. Create a new folder $INSTALL_HOME\include
  2. Copy the $BOOST_HOME\boost folder into the $INSTALL_HOME\include folder

Compiling Shared Boost (*.libs and *.dlls)

  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run "b2 --stagedir=$INSTALL_HOME toolset=msvc variant=release link=shared threading=multi runtime-link=shared -j 8"
  • A good example of $INSTALL_HOME is C:\libraries\boost-1.52.0
  1. Create a new folder $INSTALL_HOME\include
  2. Copy the $BOOST_HOME\boost folder into the $INSTALL_HOME\include folder
  3. Add $INSTALL_HOME\bin to your $PATH environment variable to pick up the dlls at runtime

Right now the CMakeLists.txt file sets some fairly strict requirements on the Boost library to help make it easier to actually find all the libraries for you. Right now it's set to use a static, multi-threaded library with a shared runtime. Unless you absolutely need to use shared Boost libraries on Windows, it is highly recommended that you use the "preferred method" above to build boost.

Linux

Compiling Boost is fairly automated. The only prerequisite is that you have gcc installed.

Compiling Bjam

  1. First download Boost-1.52.0
  2. Unzip the archive to $BOOST_HOME
  • A good example of $BOOST_HOME is /home/username/Programming/Libraries/boost-1.52.0-src
  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run ./bootstrap.sh

Compiling Shared Boost (*.so's) - Preferred Method

  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run "./b2 --stagedir=$INSTALL_HOME variant=release link=shared threading=multi runtime-link=shared -j 8"
  • A good example of $INSTALL_HOME is /home/username/Programming/Libraries/boost-1.52.0
  1. Create a new folder $INSTALL_HOME/include
  2. Copy the $BOOST_HOME/boost folder into the $INSTALL_HOME/include folder
  3. Add the $INSTALL_HOME to your $LD_LIBRARY_PATH to pick up the *.so's at runtime

Compiling Static Boost (*.a's)

  1. Open up a terminal
  2. cd to $BOOST_HOME
  3. Run "./b2 --stagedir=$INSTALL_HOME variant=release link=static threading=multi runtime-link=shared -j 8"
  • A good example of $INSTALL_HOME is /home/username/Programming/Libraries/boost-1.52.0
  1. Create a new folder $INSTALL_HOME/include
  2. Copy the $BOOST_HOME/boost folder into the $INSTALL_HOME/include folder

You can use static or shared boost libs, totally up to you. I prefer shared libs for boost on Linux.