Building Boost on Windows

11,716

Solution 1

Here is a tutorial I had written to compile Boost 1.45.0 on Windows 7 using MinGW. I copy the tutorial here in case the link breaks:

1) First we need to compile Boost. We'll use Boost's latest version: 1.45.0 (probably not the latest version at the time you'll read this tutorial.

1.1) Download Boost sources:

1.2) To compile Boost, we need to use BJam. BJam's sources are included in boost's sources. Yet, we can't use BJam's binaries: we must compile it because of the following problem: http://comments.gmane.org/gmane.comp.lib.boost.user/64146.

To compile BJam, go to Boost's sources, find build.bat (should be located in \boost_1_45_0\tools\build\v2\engine\src), run cmd, cd to build.bat's folder and execute: build.bat gcc (source)

Compilation lasts less than 30 seconds.

1.3) Once BJam is compiled, we can now compile Boost. Add bjam.exe in $PATH, run cmd, cd \boost_1_45_0 then execute:

bjam --toolset=gcc "--prefix=C:\DestinationFolder" install

where DestinationFolder is whatever folder path you want (source).

Compilation lasts around 30 minutes.

Solution 2

This thread is a year old, but I had the same problem and got it working, so in case anyone else needs a solution, here's mine.

bjam was looking for a file called "boostcpp.jam" which didn't exist in the production version of boost. Luckily, you can find it on github.

https://github.com/iNiKe/boost/blob/master/boostcpp.jam

Download that file (or copy-paste it from your browser to a new file) and save it as "boostcpp.jam" in your boost directory (or maybe it's the location where you run bjam from...they happened to be the same directory in my situation) and run the command again. Hopefully it'll work for you too.

Solution 3

For those that only need 32bit, STL's Mingw Distro has Boost included with all the libs already built for it.

Share:
11,716
Martynas
Author by

Martynas

Updated on June 30, 2022

Comments

  • Martynas
    Martynas almost 2 years

    I am trying to build boost libraries on Windows 7 x64 machine using mingw. When I try to run b2

    b2 --build-dir="C:\boost\build" --toolset=gcc --with-python
    

    to build the libraries I get an error

    Jamroot:138: in modules.load
    rule boostcpp.set-version unknown in module Jamfile</C:/Users/root/Downloads/boost_1_47_0>.
    C:/Users/root/Downloads/boost_1_47_0/tools/build/v2/build\project.jam:314: in load-jamfile
    C:/Users/root/Downloads/boost_1_47_0/tools/build/v2/build\project.jam:62: in load
    C:/Users/root/Downloads/boost_1_47_0/tools/build/v2/build\project.jam:168: in project.find
    C:/Users/root/Downloads/boost_1_47_0/tools/build/v2\build-system.jam:570: in load
    C:\Users\root\Downloads\boost_1_47_0\tools\build\v2/kernel\modules.jam:283: in import
    C:\Users\root\Downloads\boost_1_47_0\tools\build\v2\kernel\bootstrap.jam:142: in boost-build
    C:\Users\root\Downloads\boost_1_47_0\boost-build.jam:17: in module scope
    

    What am I doing wrong and how to fix it? Any help is appreciated

    Thanks

    Edit:

    I want to use boost libraries with qt sdk, which uses mingw. That's why I can't use the boost installer. Of course, unless I fail to find solution to this problem, I will have to resort to using qt built with msvc.

  • Martynas
    Martynas over 12 years
    This one didn't have libboost_python built - the one library I needed. I am probably going to move to visual studio 2008.
  • user_0
    user_0 over 4 years
    Worked fine with boost 1.70
  • vgulkevic
    vgulkevic over 3 years
    This answer is 9 years old but is so great.. Worked with boost 1.74 but I was getting some errors complaining about circular dependency or something like that. I just compiled the module I needed with by specifying, for example, --with-system. Also, note that on different version of Boost \tools\build\v2\engine\src can be slightly different (no v2 in path no src and etc) I used cmd with mingw32 bins included in the $PATH