Boost

Home page Models Systems Tools IT staff References

Installing Boost Using Boost

Boost is a large library of C++ classes and functions. The Kirshner-Linderlab models use Boost for command line argument processing and random number generation, among other things. The Main Boost web page. It also has installation instructions in the "Getting Started" link on the right side of the page. The Boost documentation web page. This has an overview of the various Boost libraries with links to more detailed documentation for each library.

Installing Boost

Linux Install Mac Install Windows Install

To get installation instructions go to the Main Boost web page and click the "Getting Started" link on the right side of the page then click the "Getting Started on Unix variants (e.g. Linux, MacOS)" link in the bottom right corner of the page. This will be for the current version of Boost, but the basic process is the same for other Boost versions as well.

Linux Install

Install From Source

Download the latest version of Boost from SourceForge, ex. http://sourceforge.net/projects/boost/files/boost. DO NOT download any beta versions. Although it doesn't really matter, it is is probably easiest to download the ".tar.bz2" file. This is a unix tar file which can be easily dealt with on Unix systems (including the Mac) and has the smallest file size. You will have a file called something like boost_MM_mm_r.tar.bz2, where MM_mm_r is the Boost version number, ex. boost_1_46_1.tar.bz2.

Installing boost: From an account with administrator privileges untar the Boost install file in /usr/local (this requires root privileges, ex. use the sudo command). This will create a directory like /usr/local/boost_1_46_1 (the exact name will depend on the Boost version) which will have many subdirectories including one called boost with the boost header files (which is most of Boost), various documentation files and a doc directory, etc. Make a link to the boost sub-directory from /usr/local/include, because /usr/local/include is searched by g++ for header files. Using a link to the currently installed Boost header files will make it easier to update to a newer version of Boost - untar the new version (which will have a different main directory name than the old version, since Boost main directory names include the Boost version number) and update the link in /usr/local/include to refer to the boost sub-directory of the new Boost version main directory.

For example, if the tar file was downloaded to ~/Downloads/boost_1_46_1.tar.bz2 (the Downloads sub-directory of your home directory) you would do the following:

This installs the Boost files, which don't include any binaries. Most of the Boost libraries are "header only" meaning that only the header files are needed - Boost header only code gets compiled when code that references a Boost header gets compiled. However, a few Boost libraries need to be compiled and installed, including the Boost program option library used by all the simulation models that use Boost and the Boost iostream library for those models that use it for saving and loading saved simulation states.

Since we occasionally add to our models use of a Boost library that needs to be compiled and installed, it is best to compile and install all of them. Use the following, which is from the directions in the Boost documentation. Some of the Boost compiled libraries require other, non-Boost libraries to be installed. These are the ones referenced in the apt-get commands below.

The bjam step takes quite awhile and shows nothing for a minute or so before displaying a lot of incomprehensible output. It may also produce fatal build errors, which may or may not be a problem. When the bjam step is complete /usr/local/lib will have static and dynamic versions of the Boost compiled libraries, such as libboost_program_options.a, libboost_program_options.so.1.46.1, libboost_program_options.so (which will be a link to the version specific file libboost_program_options.so.1.46.1). If all the expected Boost libraries are here then any build errors in the bjam are probably not a problem.

If the bjam step produces what are clearly error messages (they will contain the word "error" in them) these are probably compiler errors complaining about missing header files or linker errors complaining about missing libraries. These are probably due to a required non-Boost library not being installed. For example, this will happen if libbz2-dev is not installed when the Boost iostream library is built. In this case the corresponding Boost library will be missing from /usr/local/lib. As noted above, there may be some errors that occur that are not a problem. If all the expected Boost libraries are present in /usr/local/lib then those errors can be ignored. It is not a problem, and is quite common, to see many compiler warning messages.

Next you need to update the shared library configuration to reference the newly created program options shared library.

Install from a Package

Ubuntu has a prebuilt version of Boost that is installed using the Ubuntu package manager. This is usually for a somewhat older version of Boost, which as of this writing does not work for our models, so generally we need to install the latest version of Boost from source. To install from a Ubuntu package:

Mac Install

This is nearly identical to the Linux install the latest version of Boost from source. The only differences are:

Windows Install

There are 2 versions of Boost for the Windows development environment, one for command line use and one for Visual Studio. They should be installed in separate directories to avoid mixing runtimes between mingw and Visual Studio. For example, the Visual Studio version can be installed in the "Program Files" directory. The command line version should be installed in the Qt directory, i.e. c:\Qt\boost, since the win32 section of grviz.pro for the lung models references that specific directory.

After downloading Boost it can be built from a Qt command window using the Boost build utility. Do this using the Qt command window, not a regular Windows command window. For both the command line version and VS version there is also a pre-built version of boost for Visual Studio, available from http://www.boostpro.com/download/. This is from a commercial company that provides pre-build binary installers for Boost.

Using Boost

Determining the Boost version

Look at file version.hpp in the directory with Boost header files, typically something like /usr/local/include/boost. To access the Boost version from code reference the Boost macro BOOST_VERSION.