Building Boost 32-bit and 64-bit libraries on Windows

After completing this procedure you will have Boost's libraries in x86 and x64 variants, at the same time.

cd \where_i_extracted_boost\  
b2 --build-dir=build/x86 address-model=32 threading=multi --build-type=complete --stagedir=./stage/x86 --toolset=msvc-14.0 -j 12  
b2 --build-dir=build/x64 address-model=64 threading=multi --build-type=complete --stagedir=./stage/x64 --toolset=msvc-14.0 -j 12  

In MSVC, include them with a linker path of where_i_extracted_boost\stage\$(PlatformTarget)\lib for all configurations and all platforms, unless you're doing ARM or something like that (in which case, you do you!).

Et voilĂ .

Oh, you want I should explain?


Create b2.exe. If you have Symantec Endpoint Protection installed, this might trigger a quarantine. This would be a good time to add your development folders to your exclude list.


The build tool you just built. Replacement for bjam.


b2 caches its configuration. When you build the second library with different settings, it looks like it uses the cached settings from the first build. Specify a distinct build directory for each build, or delete bin.v2 between runs.


Build it this wide. If you thought you saw the Boost documentation claiming that it will build 64-bit by default if you're on a 64 bit host running 64-bit windows, you were clearly mistaken like I was. When you start the 64-bit build, you will see both 32-bit: yes and x86: yes. You can optionally worry about whether these instructions are actually going to work at this point, but the Py_ssize_t to unsigned int cast warnings flying by are your guarantee you've entered 64-bit flavour country.


It's 2017. Include threading support. Again, if you thought you saw the Boost documentation claiming that it will build multithreaded by default, what can I say?


Build [debug,release]x[static,shared]. That is, build all the variants so we don't have to do this again later.


By default, boost will build to stage/ both times, wiping out your first build with your second. Don't do the default thing.


It seemed to pick up MSVC14 on my system by default, but we've been burned before, haven't we? Specify explicitly. If you want to build for multiple toolsets, you can use the same stage dir -- the lib filenames specify the toolset to which they apply, so they won't collide. You'd probably want a different build-dir though.

-j 12

Boost builds on a single core by default, which is a shame because you've likely got 4, 6 or 8, times two for hyper-threading if you have that.

Et voilĂ .