How To Compile Boost Using g++ -std=c++11 From MinGW

To compile Boost using g++ -std=c++11 from MinGW, do the following:

  1. Ensure that MinGW is installed at C:\MinGW\
  2. Launch a regular Windows Command Prompt, not a MSys Command Prompt:

    cmd

  3. Ensure that the PATH Environment Variable contains C:\MinGW\bin\:

    set PATH=C:\MinGW\bin;%PATH%

  4. Change directories to Boost:

    cd C:\boost_1_54_0\

  5. Pass in mingw to bootstrap.bat:

    bootstrap.bat mingw

  6. Call b2.exe:

    b2.exe toolset=gcc cxxflags="-std=c++11" --build-type=complete stage

This will build Boost using the GCC toolset in MinGW with the g++ flags set to -std=c++11.

Note: This post was tested by compiling Boost 1.54.0 ( http://www.boost.org ) with GCC version 4.8.1 from MinGW ( http://www.mingw.org ).

The output from b2.exe using the flag cxxflags="-std=c++11" ended with:
...failed updating 156 targets...
...skipped 396 targets...
...updated 4783 targets...

Additionally, only 284 stage\lib files were built.

However, the output without using that flag ended with:
...failed updating 24 targets...
...skipped 40 targets...
...updated 5271 targets...

Additionally, 428 stage\lib files were built.

Therefore, not all stage\lib files are built using the flag cxxflags="-std=c++11".

Tagged on: , , , ,

One thought on “How To Compile Boost Using g++ -std=c++11 From MinGW

  1. Manuel Isaac

    Dear Joshua Burkholder, I am compiling a preflate compressor here in windows that is for a compressor job that I am carrying, the truth is that I had to change std :: threads for boost :: threads and that means I need the compilation of the boost .

    well first it was the job of generating the b2.exe, I had to make changes in build.bat of the tools \ build \ src \ engine directory and then I did what you propose there, with boost_1.72 for windows.

    and from there take this libboost_thread-mgw 63-mt-d-x32-1_72.dll linked with -lboost_thread-mgw63-mt-d-x32-1_72, and it worked.
    Thanks a lot of luck.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.