Short reminder on how to build Boost on Windows with MinGW.

Versions used in this how-to :

  • Boost 1.63, uncompressed in c:\src\libs\boost_1_63_0.
  • MinGW-w64 targeting 32bits, GCC 6.2, posix, sjlj. The bin subfolder is in the PATH environnement variable.

Steps :

  • Installing Boost.Build building tool.
  • Compiling Boost, selecting what to compile.

Install Boost.Build

Not sure exactly why this is needed, but let’s do it anyway… It will be installed in c:\src\libs\boost_1_63_0\BOOST.BUILD. Note: « mingw » toolset, while mentionned in the documentation, does not work. Use toolset « gcc » instead, it supports MinGW compiler.

cd c:\src\libs\boost_1_63_0\tools\build
bootstrap.bat gcc
b2 install --prefix=c:\src\libs\boost_1_63_0\BOOST.BUILD

Building Boost

When no build folder is selected, Boost.Build will build in c:\src\libs\boost_1_63_0\bin.v2, and libs will be available in C:\src\libs\boost_1_63_0\stage

set PATH=c:\src\libs\boost_1_63_0\BOOST.BUILD\bin;%PATH%
cd c:\src\libs\boost_1_63_0
b2 toolset=gcc -j 4 --build-type=complete stage

You might get errors like the following :

error: Name clash for '<pstage\lib>libboost_atomic-mgw51-mt-1_63.dll.a'
error:
error: Tried to build the target twice, with property sets having
error: these incompatible properties:
error:
error:     -  <linkflags>-shared-libgcc <linkflags>-shared-libstdc++
error:     -  none
error:
error: Please make sure to have consistent requirements for these
error: properties everywhere in your project, especially for install
error: targets.

I got this kind of error trying to build with TDM-GCC 5.1, and solved it by not building shared libraries (I usually use static so I can distribute small tools) :

b2 toolset=gcc -j 4 link=static threading=single threading=multi stage