Tuesday, October 15, 2013

Building Boost

Building Boost

When it comes to Ogre, you may notice that there are several dependencies to the boost libraries. The  Boost libraries are used mainly to add thread support to Ogre. They are not mandatory and can be replaced by other thread libraries. But I shall treat them as the default Ogre thread provider.

Download the Boost library


    This example is for building Boost version 1.54, but it can easily be adapted to other versions as well. Just make sure to adapt the paths and any place where the version is mentioned. First, download boost, using one of the available distribution methods (zip, 7z, svn) : http://www.boost.org/users/download/, and place it in a local directory. If it is an archive, decompress it :-)

    For this tutorial, I chose to download the 7z archive and extract it to a local directory. E.g. [c:\code\boost_1_54_0].



Build the Boost library

    Open a command prompt and go to the directory where you downloaded it. Run bootstrap.bat. This will build the bjam and b2 executables which will be used for the rest of the build process.
Boost: Running bootstrap
Boost: Running bootstrap

Full option

    You can choose the easy way and just build all libraries by running the command b2
(and you will need patience and about 4GB of drive space). I recommend you follow this route unless you really really have issues with the amount of available drive space.

Reduced option

    You can customize the libraries you want to build using individual bjam commands. You can restrict yourself to the most often used libraries:
  • thread
  • date_time
  • filesystem
  • chrono
  • regex
  • system
  • python
E.g.
bjam --with-thread --build-type=minimal --toolset=msvc-11.0 stage
bjam --with-thread --build-type=minimal --link=static --runtime-link=static --threading=single --toolset=msvc-11.0 stage
bjam --with-date_time --build-type=minimal --toolset=msvc-11.0 stage
bjam --with-filesystem --build-type=minimal --toolset=msvc-11.0 stage
bjam --with-regex --build-type=minimal --toolset=msvc-11.0 stage
bjam --with-system --build-type=minimal --toolset=msvc-11.0 stage
bjam --with-python --build-type=minimal --toolset=msvc-11.0 stage
Regardless of the chosen option, you should end up with plenty of files generated in the stage/lib sub-directory of the directory in which you are storing boost.

Define the BOOST environment variable

    You will also need to define an environment variable so that boost can be found by other applications. You should define the environment variable BOOST_ROOT to point to the local boost directory (E.g. [c:\code\boost_1_54_0\]).
    If you still have the cmd window opened, you can run the SETX command (not supported under Windows XP). E.g. [SetX BOOST_ROOT c:\code\boost_1_54_0]
    Alternatively, you can go to the environment variables list (Click on the Start menu, right click the Computer icon, select Properties; from there, select Advanced System Settings; next, click the Environment Variables button and use the New button to create a new user variable with the name BOOST_ROOT and the value c:\code\boost_1_54_0 (or whatever you specified as the directory).

No comments:

Post a Comment