wiki:Boost_Build_Visual_Studio_Integration

How can I integrate Boost.Build into Visual C++ 2005

(The steps that I detail here are based off instructions I found in in this post http://qemu-forum.ipi.fi/viewtopic.php?t=1871)

Assumptions

  • I assume that you already have a working installation of Boost.Build on your system.
  • I assume that you already have a working installation of Visual Studio 2005.

Directory Rational

As I like to keep things fairly neat I have separate directories for my src (with jam files) and my Visual Studio Solutions. This has complicated my instructions slightly but for those interested in this without this additional complication it is straight forward to remove this.

You just need to keep two things in mind:

  1. When creating the solution point it to the location you have the jamroot located at; and
  2. When adding the command line build instructions remove "&& path_to_jamroot.bat" from the command line.

Setting up Visual Studio

1. Open Visual Studio; Open the "File Menu" and select "New" and then "Project"

2. Expand "Visual C++" and click on "General" project type and then select the "Makefile Project" template.

3. Give the Project a Name (for this example "BB_MSVC_Int"), location ("e:\dev\VS Projects") and fill in the other details.

New Project window

4. Click "Next"

5. Fill in the "Debug Configuration Settings". For my configuration I use:

  • Build Command Line - E:\dev\tools\bjam\bin\bjam_setup.bat && path_to_jamroot.bat && bjam.exe -d0 variant=debug
  • Clean Commands - E:\dev\tools\bjam\bin\bjam_setup.bat && path_to_jamroot.bat && bjam.exe --clean variant=debug
  • Rebuild Command Line - E:\dev\tools\bjam\bin\bjam_setup.bat && path_to_jamroot.bat && bjam.exe -a -d0 variant=debug

Updated file to correct error

6. Fill in the "Release Configuration Settings". For my configuration I use:

  • Build Command Line - E:\dev\tools\bjam\bin\bjam_setup.bat && path_to_jamroot.bat && bjam.exe -d0 variant=release
  • Clean Commands - E:\dev\tools\bjam\bin\bjam_setup.bat && path_to_jamroot.bat && bjam.exe --clean variant=release
  • Rebuild Command Line - E:\dev\tools\bjam\bin\bjam_setup.bat && path_to_jamroot.bat && bjam.exe -a -d0 variant=release

Updated file to correct error

What are the two batch files (bjam_setup and path_to_jamroot) doing?

The contents of each file is as follows:

bjam_setup.jam

I store this file with the BJAM executable as it is general across projects.

@echo off

REM Add the bjam\bin to the path so I can use Boost.Build anywhere.

SET PATH=%PATH%;E:\dev\tools\bjam\bin

REM Tell BJAM where the boost-build.jam file is

SET BOOST_BUILD_PATH=E:\dev\tools\bjam\bin

REM Tell BJAM where my user-config.jam file is

SET BOOST_BUILD_USER_CONFIG=%HOMEDRIVE%%HOMEPATH%\My Documents\user-config.jam

path_to_jamroot.jam

This file is specific for each Visual C++ project you use. This should be stored in the same directory that the project is located in.

@Echo Off

Set drive_letter=E:
Set jamroot_path=\dev\src\hello

cd %drive_letter%
cd %jamroot_path%

7. You should now be able to use Boost.Build within Visual C++ 2005. Lets test it!

Using the Boost Build Examples to test this!

I am going to test this against the libraries example located within the Boost.Build examples directory. My "path_to_jamroot.bat" looks like this:

@Echo Off

Set drive_letter=E:
Set jamroot_path=\dev\tools\071006-boost-build\example\libraries

cd %drive_letter%
cd %jamroot_path%

Example - Libraries

Conclusion

As you can see it was fairly straight forward to set this up. It is also possible to create additional build configurations and have these relate to different Boost.Build vairant's (exe, pdf, html ...).

Last modified 15 years ago Last modified on Oct 6, 2007, 3:49:49 AM

Attachments (4)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.