Building Boost (now with dual/quad/multi-core action!)

— richardwb on Monday, March 02, 2009 @ 16:27

Update: More recent versions of Boost (1.39.0 and later) have a simpler build process, which I've written about here.

Steps to build the non-header-only Boost libraries on Windows, such as Boost.Thread and Boost.Regex, using Microsoft Visual Studio:

  1. Download the latest version of Boost and extract it to some location, say, D:\Boost\, making sure to maintain the directory structure

  2. Download the latest version of Boost Jam (you want the ntx86 binaries) and extract it to some location (probably the same as above), again making sure to maintain the directory structure

  3. Your directory structure should now consist of D:\Boost\boost_1_38_0\ and D:\Boost\boost-jam-3.1.17-1-ntx86\

  4. Make sure you have lots of hard drive space (at least 5GB)

  5. In a command prompt, navigate to your Boost library folder (D:\Boost\boost_1_38_0\) and then use this command (read further down if you want details about what these arguments are doing):

    > ..\boost-jam-3.1.17-1-ntx86\bjam.exe --toolset=msvc --build-type=complete stage
    
  6. If you have a dual/quad/many-core processor or can otherwise take advantage of parallel jobs, also add the -jN switch, where N is the number of jobs to run at a time (e.g. bjam.exe -j4 --toolset=msvc).

  7. And wait. This will take a very long time.

  8. After it completes you will have a stage subdirectory (D:\Boost\boost_1_38_0\stage\) which will contain a lib subdirectory, containing the compiled libraries. You may move these anywhere you wish.

  9. You will also have a bin.v2 subdirectory which was used for temporary files. You may delete this folder to reclaim some hard drive space.

More details:

--toolset=msvc : tells Boost Jam to compile with Microsoft Visual Studio.

--build-type=complete : notes that you want every possible combination built (Debug/Release, Multi/Single threaded, Static/Shared).

stage : a build target which builds the compiled libraries to the stage directory (which you can set with --stagedir=<STAGEDIR>). Contrast this with the install target, which builds the compiled libraries, but also copies the header-only libraries to a particular location. This is generally an unnecessary step since you've already extracted the Boost headers somewhere already. Look inside the Jamroot file inside your Boost folder for more details.

comments powered by Disqus