BOOST |
---|
Description: free peer-reviewed portable C++ source libraries |
SHARCNET Package information: see BOOST software page in web portal |
Full list of SHARCNET supported software |
Contents
Operating System Installed Boost
The version of boost and boost-devel packages installed are provided with the native operating system and not provided by a SHARCNET module hence they are available by default.
To get the latest version information about the packages do:
rpm -qi boost rpm -qi boost-devel
To get a listing of files for each package do:
rpm -ql boost rpm -ql boost-devel
Compiling Your Own Version Of Boost
Unfortunately, the operating system-installed version of the Boost libraries are usually out of date and programs relying on boost libraries may require a later version. Please check the documentation of the package you are trying to link to boost libraries to see which version is the minimum required. If this minimum is later than the native system libraries, you will have to install the newer boost libraries on your own.
Manually Building Boost
The following are the steps to manually build Boost from the command-line.
- Download Boost from http://www.boost.org
- Extract the file downloaded into an empty directory using one of these commands:
-
unzip boost_VERSION.tar.gz
-
tar xvzf boost_VERSION.tar.gz
-
tar xvjf boost_VERSION.tar.bz2
- NOTE: This top directory holding the uncompressed Boost files will be called
$BOOST_SRC
below.
-
- Decide on which C++ compiler you are going to use (e.g., GCC, Intel, PGI). Once that is done, use SHARCNET's module system to unload any previous compiler and load the one you need:
- Unload C++ compiler modules:
module unload gcc intel pgi
- Load the GCC v4.8.2 module example:
module load gcc/4.8.2
- Unload C++ compiler modules:
- Decide on whether or not you want MPI support (and load the one suitable for the compiler you've chosen):
- Unload the module:
module unload openmpi
- Load MPI for GCC example:
module load openmpi/gcc
(Omit this line if you don't need MPI.)
- Unload the module:
- Decide whether or not you need Python support (and load the one suitable for the compiler you've chosen).
- Unload the module:
module unload python
- Load Python for GCC module:
module load python/gcc
(Omit this line if you don't need Python.) - NOTE: Boost will use the system's Python if you don't load the module which is okay if you don't need Python.
- Unload the module:
- Change the directory to
$BOOST_SRC
:-
cd $BOOST_SRC
-
- NOTE: Because SHARCNET has many compilers and tools available, avoid using the shortcut method to building Boost --build Boost's
b2
program instead. - Change the directory to build bjam:
-
cd tools/build/v2
-
- For the aforementioned selected C++ compiler, determine the correct
--with-toolset
option forbootstrap.sh
:-
./bootstrap.sh --with-toolset=help
(This command is designed to fail.) -
less booststrap.log
-
- Replace TOOLSET_NAME_FROM_FILE with the appropriate toolset mentioned in the
bootstrap.log
file and the run:-
./bootstrap.sh --with-toolset=TOOLSET_NAME_FROM_LOG_FILE
- e.g.,
./bootstrap.sh --with-toolset=gcc
- e.g.,
./bootstrap.sh --with-toolset=intel-linux
- e.g.,
./bootstrap.sh --with-toolset=pgi
-
- Decide on a directory you want to install Boost build into.
- This directory will be referred to as
$BUILD_DIR
below.
- This directory will be referred to as
- Run:
-
./b2 install --prefix=$BUILD_DIR
-
- Add
$BUILD_DIR/bin
to your PATH (in your shell):- PATH=$BUILD_DIR/bin:$PATH
- export PATH
- If you need Boost MPI, then add the following text to a line of its own in
user-config.jam
:-
using mpi ;
-
- Go back up to the
$BOOST_SRC
directory:-
cd ../../..
-
- Decide on an empty directory where you want to install the Boost libraries.
- This directory will be referred to as
$INSTALL_DIR
below.
- This directory will be referred to as
- If you would like Boost to build its libraries in parallel, decide on the number of parallel processes.
- This number will be referred to as
$NUM_PROCS
below.
- This number will be referred to as
- Although it is usually the same as the above, determine the toolset (referred to as $TOOLSET below) you need from the Boost documentation:
- Version 1.55.0: http://www.boost.org/doc/libs/1_55_0/more/getting_started/unix-variants.html#toolset
- Version 1.54.0: http://www.boost.org/doc/libs/1_54_0/more/getting_started/unix-variants.html#toolset
- Version 1.53.0: http://www.boost.org/doc/libs/1_53_0/more/getting_started/unix-variants.html#toolset
- Version 1.52.0: http://www.boost.org/doc/libs/1_52_0/more/getting_started/unix-variants.html#toolset
- etc.
- Build the Boost libraries by running:
- Normal sequential build:
b2 --prefix=$INSTALL_DIR --build-dir=$BUILD_DIR toolset=$TOOLSET install
- Parallel build:
b2 -j$NUM_PROCS --prefix=$INSTALL_DIR --build-dir=$BUILD_DIR toolset=$TOOLSET install
- Normal sequential build:
- If all of the above went well, you're done building Boost!
Please note the following:
-
BOOST_HOME=$INSTALL_DIR
- The INCLUDE directory for Boost is
$BOOST_HOME/include
. - The LIBRARY directory for Boost is
$BOOST_HOME/lib
.
To build programs use the -I, -L, and -l options to specify the top include file directory, the top library directory and any specific libraries that must be linked in to your program, e.g.,
- A program that uses header-only libraries:
$CXX -I $BOOST_HOME/include program1.cxx
- A program that uses the Boost regex library:
$CXX -I $BOOST_HOME/include -L $BOOST_HOME/lib -lboost_regex program2.cxx
- etc.
Finally remember to BEFORE running your programs you will ALWAYS need to "module unload" and "module load" the settings for any new shells you create. This can be a nuisance --you might prefer to place those unload and load commands at the bottom of your ~/.bashrc file.
References
o Boost Homepage
http://www.boost.org/