Boost C++ libraries on Windows with MinGW

Last Modified: Wed, 22 Feb 2012 17:43:32 +0000 ; Created: Wed, 22 Feb 2012 17:42:37 +0000

I like to use Boost because it makes cross-platform programming easier. I also prefer to use a non-Visual Studio compiler such as MinGW. I needed to install the Boost headers (latest version) along with compiling the extended libraries. I outline the steps below (at the time I used Boost 1.48.0):

Prerequistes

  1. Boost
  2. MinGW with MSYS - I used the nice auto-installer. You could also use Visual C++ as your compiler
  3. MinGW & MSYS in your path (for my system it was C:\mingw\msys\1.0\bin;C:\mingw\bin)
  4. Lots of time to wait on the compile

Steps

  1. Extract Boost somewhere (takes a while)
    • I used C:\boost_1_48_0 to avoid spaces in paths
  2. Open a command prompt (cmd) and go to C:\boost_1_48_0\tools\build\v2
  3. gcc --version to make sure it is in your path
  4. bootstrap.bat gcc
  5. b2.exe install --prefix=C:\boost_1_48_0
  6. set PATH=%PATH%;C:\boost_1_48_0\bin
  7. b2 -j4 toolset=gcc --build-type=complete stage
    • Note that -j4 means use 4 cores. Adjust as needed.
  8. Your compiled libs will be in C:\boost_1_48_0\stage\lib