My blog has moved!

Please visit
http://blog.programmerslog.com
and update your bookmarks.

03 October 2006

Boost Library And Visual Studio 2005

This will set you up with a top notch development environment for C++ in Windows. Also this will tell you how to get the Boost::Python libraries to work with as well (which can never be a bad thing).

  1. Download Visual C++ 2005 Express from here.
  2. Then go and install the Platform SDK. I recommend installing it into C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK as then the environment variables are already set up for you in VC8.
  3. Go and download Python where the latest version is 2.5. Install Python 2.5 to the default installation directory of c:\Python25.
  4. Now it is time to download Boost and make sure you download the source and a precompiled bjam build tool.
  5. Extract Boost to a temporary directory on your hard drive, and copy the bjam.exe into the Boost directory.
  6. Open a command prompt in the Boost root directory(where you copied bjam.exe to).
  7. Run the batch file for registering Visual Studio commandline variables : C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat
  8. Run the following command line to compile and install Boost in "c:\Boost" with no checked iterators:bjam "-sTOOLS=vc-8_0" "-sPYTHON_VERSION=2.5" "-sPYTHON_ROOT=c:\Python25" "-sBUILD=debug release <define>_CRT_NONSTDC_NO_DEPRECATE <define>_CRT_SECURE_NO_DEPRECATE <define>_SECURE_SCL=0 <define>_SCL_SECURE_NO_DEPRECATE <define>_HAS_ITERATOR_DEBUGGING=0" install
  9. What I tend to do then is copy Boost to where my development libraries go, and then add those directories to the lib and include directories in Visual C++.
Now you are ready to go for Boost-ified C++ development and you will have the Boost Python libraries as well for binding your code to a scripting language. Next install TortoiseSVN and install the settings outlined in one of my previous posts for the toolbars, and then you should be ready to check some code out and develop like a demon.

3 comments:

dtinkham said...

Hi Garry,

I don't think that the command-line to bjam that you list is exactly right. With the preprocessor options/defines listed as you have them, bjam interprets the defines as targets, and you get 4 extra builds :)

It looks like each define should have < define > prepended.

e.g.

< define >_CRT_SECURE_NO_DEPRECATE

Note, there should not be a space between the <, >, and the word define. I had to put the space in because the blog commenter won't allow that tag.

Cheers.

Garry Bodsworth said...

Oh damn! That means I have been using it without all the switched off stuff. Thanks for the heads up.

Unfortunately running bjam verbosely gives far too much output, but I have also fixed another problem I spotted as it whizzed past on the DOS command prompt (to do with deprecated C library functionality).

There is still the "Og" flag warning but hopefully that will be fixed in Boost 1.34 as it is not a problem in VC++ 8 (but will be when it is removed in future versions).

Check out the updated post. Overall it makes the Boost library build a whole 1Mb smaller ;)

Thanks!

Garry

Paul said...

To stop things whizzing past, run it at the command line like so:

bjam blah blah > build_log.txt 2>&1

then open up the text file in a good text editor and reload to watch the new stuff come in...