Pages

Boost 1.49 beta and MSVC

I have just installed the latest the Boost libraries, 1.49, currently available in beta version (now the definitive 1.49 version is out), to use them with my MSVC 2010 development environment.

The setup procedure is always the same, but maybe it could be useful to have a refresh.

First thing, a few useful links.

The sourceforge download page for the 1.49 beta 1 version.

The latest Boost libraries release documentation root page.

The Boost getting started for Windows page.

Once you download the libraries from sourceforge, you have to build Boost for MSVC (if this is the compiler you plan to use, please refer to the above Boost documentation for other compilers). You can do it in a few different ways, I prefer to go for this procedure:

1) Open Visual Studio Command Prompt
2) Go to your Boost root directory
3) Run
bootstrap
4) If no error message is raised, run
.\b2
Wait for a (longish) while, at the end you should get this message:
The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    D:/dev/boost_1_49_0_beta1

The following directory should be added to linker library paths:

    D:\dev\boost_1_49_0_beta1\stage\lib
Well, directory names would probably be different, but that is the spirit.

The Boost libraries are ready to be used in a project, we just have to tell the compiler where to find .lib and include files.

Include files

Open the project's properties, go to the Configuration Properties, C/C++, General tab, and insert in the Additional Include Directories your root Boost directory.

Libraries

If you don't do this step, and try to compile anyway, you get an error like this:
LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc100-mt-gd-1_49.lib'
Theoretically speaking, you should provide the full name for each library your code refers to. We can save a big part of this tedious job thanks to the "auto-linking support" feature, that requires us to provide just the directory where the compiler has to look for the .lib file.

Again in the project's properties, we go this time to Configuration Properties, Linker, General tab, and add to the Additional Library Directories the Boost lib directory, as specified by b2.

That's it. Have fun with Boost!

No comments:

Post a Comment