Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing boost libraries for GCC (MinGW) on Windows

Installing boost libraries for GCC (MinGW) on Windows

Folder setup

  1. Extract downloaded boost source, e.g. C:\Program Files\boost_1_59_0.
  2. Create a folder for Boost.Build installation, e.g. C:\Program Files\boost-build.
  3. Create a folder within for building, i.e. C:\Program Files\boost_1_59_0\build.
  4. Create a folder for installation, e.g. C:\Program Files\boost.

GCC setup

  1. Open Command Prompt.
  2. Run g++ --version.
  3. If the output contains g++ version number then GCC should be set up properly to run from command line and you can continue.

Boost.Build setup

  1. Open Command Prompt and navigate to C:\Program Files\boost_1_59_0\tools\build.
  2. Run bootstrap.bat mingw.
  3. Run b2 install --prefix="C:\Program Files\boost-build".
  4. Add C:\Program Files\boost-build\bin to Windows PATH.

boost building

  1. Open Command Prompt and navigate to C:\Program Files\boost_1_59_0.
  2. Run
b2 --build-dir="C:\Program Files\boost_1_59_0\build" --prefix="C:\Program Files\boost" toolset=gcc install

Project setup

  1. Add include folder, i.e. C:\Program Files\boost\include\boost-1_59.
  2. Add linker folder, i.e. C:\Program Files\boost\lib.
  3. Link required libraries, e.g. libboost_regex-mgw48-mt-1_59.a.
@okere-prince

This comment has been minimized.

Copy link

commented Mar 19, 2017

Thanks a lot for this nice and clear procedure.
It was really helpfull for me :). However it seems that the command bootstrap.bat mingw didn't work for me (I tried this with boost_1_63_0). I used bootstrap.bat gcc instead and it was fine.
Cheers

@j4cobgarby

This comment has been minimized.

Copy link

commented Sep 4, 2017

I agree with okere-prince - the whole tutorial was very helpful except you should change bootstrap.bat mingw to boostrap.bat gcc, in fact mingw isn't even a valid toolset.

@andreoliveira31

This comment has been minimized.

Copy link

commented Sep 4, 2017

I agree with both okere and j4cob, please update the tutorial.

@RafaelMH

This comment has been minimized.

Copy link

commented Sep 27, 2017

Thank you so much for this, I was starting to get desperate.

Also, as of boost 1.65.1 you should still change bootstrap.bat mingw to boostrap.bat gcc.

@Sk3pper

This comment has been minimized.

Copy link

commented Oct 1, 2017

I don't understand the last part, "Project setup". What have I to do? Where have I to add that folders (lib, include ecc)?

@vitor-alves

This comment has been minimized.

Copy link

commented Oct 18, 2017

bootstrap.bat mingw worked for me in 1.65.1

@BramVanroy

This comment has been minimized.

Copy link

commented Jul 6, 2018

I'm also confused about the last part. Could you elaborate on this? What should be linked and how.

@andyspurgeon

This comment has been minimized.

Copy link

commented Jul 13, 2018

Just a note that for Boost 1.67.0, I had to go back to bootstrap.bat gcc instead of mingw. Not sure if that's something in the Boost build system or my setup, but it worked.

@BramVanroy, the project setup depends on what you are developing using Boost. Boost is composed of multiple libraries. So, you typically don't include/link all of Boost -- you only use what you need. See this link for a list of the individual Boost libraries.

@zrsmithson

This comment has been minimized.

Copy link

commented Sep 20, 2018

When running the first b2, no toolset is given. Does this matter for the first build? When run it gives:

warning: No toolsets are configured.
warning: Configuring default toolset "msvc".
warning: If the default is wrong, your build may not work correctly.
warning: Use the "toolset=xxxxx" option to override our guess.
warning: For more configuration options, please consult
warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html

warning: Did not find command for MSVC toolset. If you have Visual Studio 2017 installed you will need to specify the full path to the command, set VS150COMNTOOLS for your installation, or build from the 'Visual Studio Command Prompt for VS 2017'.

@kailashkai28

This comment has been minimized.

Copy link

commented Oct 11, 2018

bootstrap.bat gcc is working for all the boost versions.

@mitevdev

This comment has been minimized.

Copy link

commented Oct 31, 2018

bootstrap.bat gcc completed successfully but when I run b2 install --prefix="C:\Program Files\boost-build I get

warning: No toolsets are configured.
warning: Configuring default toolset "msvc".
warning: If the default is wrong, your build may not work correctly.
warning: Use the "toolset=xxxxx" option to override our guess.
warning: For more configuration options, please consult
warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html

bootstrap.log looks fine all sources have been compiled successfully.

UPDATE: I had to give full access to the user on c:\Program Files\boost-build and it worked.

@hextakatt

This comment has been minimized.

Copy link

commented Nov 3, 2018

warning: No toolsets are configured.
warning: Configuring default toolset "msvc".
warning: If the default is wrong, your build may not work correctly.
warning: Use the "toolset=xxxxx" option to override our guess.
warning: For more configuration options, please consult
warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html
"C:\Program" no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
error: no Jamfile in current directory found, and no target references specified.
I'm running cmd.exe in administrator mode.

@RichardTMiles

This comment has been minimized.

Copy link

commented Dec 21, 2018

Hero, saint, and scholar. Thank you!

@zafaryabRasool

This comment has been minimized.

Copy link

commented Apr 5, 2019

How to do project setup point 3?

following the whole procedure, when i run my code, it says:
fatal error: boost/geometry/geometries/geometries.hpp: No such file or directory.

Any reasons?

@Iman1221

This comment has been minimized.

Copy link

commented May 30, 2019

what to do with :
Project setup!!!!!!!!!!!!!!!!

@Greg-Tarr

This comment has been minimized.

Copy link

commented Jun 12, 2019

bootstrap.bat mingw works in 1_55_0. It works if you have mingw set up correctly in PATH.

@Pirgosth

This comment has been minimized.

Copy link

commented Jul 10, 2019

You can reduce significantly compilation time for the second b2 step by adding the -j N parameter where N is the number of thread you want (it can be little higher than number of core of your CPU) according to here:
https://stackoverflow.com/questions/33566782/building-all-of-boost-in-a-few-minutes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.