How do I build Boost 1.55 with MinGW?

I have downloaded Boost 1.55 and MinGW.

The console answers me that I haven't any command. I can't understand how to bind two paths and activate the GCC compiler.

P.S.: If I build boost with Microsoft's compiler I will have about 8 mistakes with error 3861!!

How can I build it?


First make sure your mingw's bin directory is in your environment PATH so gcc and g++ is callable from your command prompt. Afterwards go into your boost's root directory of where you extracted the files.

Follow that with a bootstrap + b2.exe to build. For example, let's say you only want to compile the regex portion of boost. The follow commands should do the trick:

bootstrap gcc
b2 toolset=gcc regex

You can use:

b2 --show-libraries

to get a listing of modules you can build individually. Of course you can build all of them with just:

b2 toolset=gcc

Check out Boost Invocation for a detailed list of available options.

Greatwolf's answer didn't work for me, so here's how I managed to get it working.

First, make sure MinGW\bin is on your path

Go to the tools\build\v2 directory of your boost folder. For example, in my case it was C:\Boost\boost_1_55_0\tools\build\v2. Then run

bootstrap mingw

After that, switch to the root Boost directory (this part is important since b2 detects what to build based on current directory)

Now, if you want to build Filesystem, do

tools\build\v2\b2 toolset=gcc --build-type=complete stage --with-filesystem

This will put libboost_filesystem-mgw48-d-1_55.dll etc. in stage\lib. If you want to build everything, just leave off the --with-filesystem part.

I was able to build it following the instructions from Antimony. However I initially got this error:

Bootstrapping the build engine
\Windows was unexpected at this time.

The error was solved by clearing the PATH variable and putting just the MinGW folder in it:

set PATH=C:\MinGW\bin

Then Antimony's instructions did the job for me. Thanks!!

Just two other small things that might be helpful. BOOST for MinGW should be build from the Windows shell, not from the MSYS shell. And in version 1.57 the bootstrap.bat script is no longer in tools\build\v2, but directly in tools\build.

If you have installed MinGW/GCC as part of TDM-GCC, you will have a "MinGW Command Prompt" that you can launch. This loads a command prompt window and puts the GCC compiler on the PATH for that window. (Similar to the "Developer Command Prompt" that is installed with Visual Studio.)

I think that the "MinGW distro" comes with one too.

If you have an integrated command prompt you can simply:

  • Launch "MinGW Command Prompt"
  • Go to your Boost folder (e.g. C:/Boost)
  • Run bootstrap gcc
  • Run b2 toolset=gcc (or whatever b2 command you need)

If you are working from examples where someone is not explicitly setting the toolset, you will have to add toolset=gcc yourself. Note that toolset must be placed in the property position not the option or command position. From b2 --help:

b2 [options] [properties] [install|stage]

So if someone was writing the command to invoke the install command with the --prefix option, they'd write it as:

b2 --prefix=C:\boost-build install

And you'd re-write it as:

b2 --prefix=C:\boost-build toolset=gcc install

See b2 --help for more details.

Need Your Help

Suggested Compression Ratio with H.264?

video compression video-encoding h.264

Note bene: I realize this is an immensely complicated question with about a million levels of nuance that I'm trying to reduce to a single number...

Entity framework and many to many queries unusable?

.net entity-framework many-to-many

I'm trying EF out and I do a lot of filtering based on many to many relationships. For instance I have persons, locations and a personlocation table to link the two. I also have a role and personrole