From Documentation
Jump to: navigation, search
m (Compiling Your Own Version Of Boost)
Line 5: Line 5:
 
}}
 
}}
  
 +
== SHARCNET-Provided Boost Modules ==
  
== Operating System Installed Boost ==
+
=== Which Versions of Boost are Available? ===
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:
+
SHARCNET has a number of Boost versions available as special modules. The available versions can be viewed by running:
 +
<pre>
 +
module avail boost
 +
</pre>
 +
and/or by viewing the [https://www.sharcnet.ca/my/software/show/137 BOOST software page in the web portal].
  
 +
At the present time, when you look up the available boost modules you will see output such as:
 
<pre>
 
<pre>
rpm -qi boost
+
$ module avail boost
rpm -qi boost-devel
+
 
 +
------------------------------------ /opt/sharcnet/modules -------------------------------------
 +
boost/gcc482-openmpi183/1.50.0  boost/intel12-openmpi162/1.50.0
 +
boost/gcc482-openmpi183/1.53.0  boost/intel12-openmpi162/1.53.0
 +
boost/gcc482-openmpi183/1.55.0  boost/intel12-openmpi162/1.55.0
 +
boost/gcc482-openmpi183/1.57.0  boost/intel12-openmpi162/1.57.0
 +
boost/intel/1.55.0              boost/intel15-noopenmpi/1.57.0
 +
 
 +
------------------------------------ /opt/sharcnet/modules -------------------------------------
 +
boost/gcc482-openmpi183/1.50.0  boost/intel12-openmpi162/1.50.0
 +
boost/gcc482-openmpi183/1.53.0  boost/intel12-openmpi162/1.53.0
 +
boost/gcc482-openmpi183/1.55.0  boost/intel12-openmpi162/1.55.0
 +
boost/gcc482-openmpi183/1.57.0  boost/intel12-openmpi162/1.57.0
 +
boost/intel/1.55.0              boost/intel15-noopenmpi/1.57.0
 +
$
 
</pre>
 
</pre>
  
To get a listing of files for each package do:
+
i.e., the following versions of Boost are available:
 +
# Boost versions 1.50, 1.53, 1.55, and 1.57 for GCC v4.8.2 and OpenMPI v1.8.3
 +
# Boost versions 1.50, 1.53, 1.55, and 1.57 for Intel v12 and OpenMPI v1.6.2
 +
# Boost version 1.57 for Intel v15 without OpenMPI features (i.e., the "noopenmpi" item).
  
 +
'''NOTE:''' The boost/intel/1.55.0 module should not be used --it is older and will be removed in the near future. Use one of the other Boost modules instead.
 +
 +
All of the aforementioned versions of Boost have been built with the operating system's installed Python. You can see which version of Python it will use by running:
 
<pre>
 
<pre>
rpm -ql boost
+
rpm -qi python
rpm -ql boost-devel
+
 
</pre>
 
</pre>
  
 +
'''NOTE:''' If you need a specific version of Boost compiled for a specific C++ compiler, version of OpenMPI, and/or a specific version of Python, then submit a ticket requesting such. Be sure to mention all required software packages and which versions are needed.
  
== 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.
+
=== Using a Specific Version of Boost ===
  
=== Manually Building Boost ===
+
To use a specific version of Boost, do the following:
 +
* Unload any loaded OpenMPI modules that will conflict.
 +
* Unload any loaded C++ compiler modules that will conflict.
 +
* Load any required C++ and OpenMPI modules.
 +
* Load the required version of Boost.
 +
e.g.,
 +
<pre>
 +
$ module list                                # View which modules are currently loaded
 +
$ module unload openmpi/intel/1.6.2          # Unload the OpenMPI (for Intel)
 +
$ module unload intel/12.1.3                  # Unload the Intel C++ compiler
 +
$ module load gcc/4.8.2                      # Load GCC v4.8.2
 +
$ module load openmpi/gcc/1.8.3              # Load OpenMPI (for GCC)
 +
$ module load boost/gcc482-openmpi183/1.57.0  # Load Boost v1.57 for GCC 4.8.2 and OpenMPI v1.8.3
 +
</pre>
  
The following are the steps to manually build Boost from the command-line.
+
Once this is done, you may use Boost (e.g., write #include <boost/filesystem.hpp> in your code, etc.). No special compiler options will be required.
  
# Download Boost from http://www.boost.org
 
# Extract the file downloaded into an empty directory using one of these commands:
 
#* <code>unzip boost_VERSION.tar.gz</code>
 
#* <code>tar xvzf boost_VERSION.tar.gz</code>
 
#* <code>tar xvjf boost_VERSION.tar.bz2</code>
 
#* '''NOTE:''' This top directory holding the uncompressed Boost files will be called <code>$BOOST_SRC</code> 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: <code>module unload gcc intel pgi</code>
 
#* Load the GCC v4.8.2 module example: <code>module load gcc/4.8.2</code>
 
# Decide on whether or not you want MPI support (and load the one suitable for the compiler you've chosen):
 
#* Unload the module: <code>module unload openmpi</code>
 
#* Load MPI for GCC example: <code>module load openmpi/gcc</code> '''(Omit this line if you don't need MPI.)'''
 
# Decide whether or not you need Python support (and load the one suitable for the compiler you've chosen).
 
#* Unload the module: <code>module unload python</code>
 
#* Load Python for GCC module: <code>module load python/gcc</code> '''(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.
 
# Change the directory to <code>$BOOST_SRC</code>:
 
#* <code>cd $BOOST_SRC</code>
 
# '''NOTE:''' Because SHARCNET has many compilers and tools available, avoid using the shortcut method to building Boost --build Boost's <code>b2</code> program instead.
 
# Change the directory to build bjam:
 
#* <code>cd tools/build/v2</code>
 
# For the aforementioned selected C++ compiler, determine the correct <code>--with-toolset</code> option for <code>bootstrap.sh</code>:
 
#* <code>./bootstrap.sh --with-toolset=help</code> '''(This command is designed to fail.)'''
 
#* <code>less booststrap.log</code>
 
# Replace TOOLSET_NAME_FROM_FILE with the appropriate toolset mentioned in the <code>bootstrap.log</code> file and the run:
 
#* <code>./bootstrap.sh --with-toolset=TOOLSET_NAME_FROM_LOG_FILE</code>
 
#* e.g., <code>./bootstrap.sh --with-toolset=gcc</code>
 
#* e.g., <code>./bootstrap.sh --with-toolset=intel-linux</code>
 
#* e.g., <code>./bootstrap.sh --with-toolset=pgi</code>
 
# Decide on a directory you want to install Boost build into.
 
#* This directory will be referred to as <code>$BUILD_DIR</code> below.
 
# Run:
 
#* <code>./b2 install --prefix=$BUILD_DIR</code>
 
# Add <code>$BUILD_DIR/bin</code> 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 <code>user-config.jam</code>:
 
#* <code>using mpi ;</code>
 
# Go back up to the <code>$BOOST_SRC</code> directory:
 
#* <code>cd ../../..</code>
 
# Decide on an empty directory where you want to install the Boost libraries.
 
#* This directory will be referred to as <code>$INSTALL_DIR</code> below.
 
# 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 <code>$NUM_PROCS</code> below.
 
# 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: <code>b2 --prefix=$INSTALL_DIR --build-dir=$BUILD_DIR toolset=$TOOLSET install</code>
 
#* Parallel build: <code>b2 -j$NUM_PROCS --prefix=$INSTALL_DIR --build-dir=$BUILD_DIR toolset=$TOOLSET install</code>
 
# If all of the above went well, you're done building Boost!
 
  
'''NOTE:''' <code>b2</code> and the code in <code>$BUILD_DIR</code> is only needed to build Boost. You can delete <code>$BUILD_DIR</code> after Boost has been built by running <code>rm -rf $BOOST_DIR</code>.
+
=== If Special Compiler Options are Required ===
  
 +
If you are not having success building your code using Boost (e.g., in a Makefile), you might need to manually specify the INCLUDE and LIB directories. You can get these paths by running the following command (replacing the full Boost module name with the one you've loaded), e.g.,
 +
<pre>
 +
$ module show boost/gcc482-openmpi183/1.57.0
 +
-------------------------------------------------------------------
 +
/opt/sharcnet/modules/boost/gcc482-openmpi183/1.57.0:
  
=== Compiling and Linking to the Boost Libraries + Running Executables ===
+
module-whatis    Provides boost 1.57.0 (flavor gcc482-openmpi183) built using gcc/4.8.2, openmpi/gcc/1.8.3 on centos64.
 +
conflict        intel
 +
conflict        pgi
 +
conflict        python
 +
prereq  gcc/4.8.2
 +
prereq  openmpi/gcc/1.8.3
 +
prepend-path    --delim  CPPFLAGS -I/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/include
 +
prepend-path    --delim  LDFLAGS -L/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/lib
 +
prepend-path    LD_RUN_PATH /opt/sharcnet/boost/1.57.0/gcc482-openmpi183/lib
 +
-------------------------------------------------------------------
  
Please note the following:
+
$
* <code>BOOST_HOME=$INSTALL_DIR</code>
+
</pre>
* The INCLUDE directory for Boost is <code>$BOOST_HOME/include</code>.
+
The options you need to pass to the C++ compiler / linker follow CPPFLAGS and LDFLAGS in the above output, i.e., you will need to add these two options to your C++ compiler's command line:
* The LIBRARY directory for Boost is <code>$BOOST_HOME/lib</code>.
+
* -I/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/include
 +
* -L/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/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: <code>$CXX -I $BOOST_HOME/include program1.cxx</code>
 
* A program that uses the Boost regex library: <code>$CXX -I $BOOST_HOME/include -L $BOOST_HOME/lib -lboost_regex program2.cxx</code>
 
* etc.
 
  
If your <code>$BOOST_HOME</code> is not in a system-wide library directory, your compile program won't run. You can ensure it does run by adding <code>$BOOST_HOME/lib</code> to your <code>LD_LIBRARY_PATH</code> (once per shell) as follows:
+
== Operating System Installed Boost ==
* <code>LD_LIBRARY_PATH=$BOOST_HOME/lib:$LD_LIBRARY_PATH</code>
+
If you don't load any SHARCNET-provided Boost module, you will be using the operating system's installed version of Boost. To determine which version(s) of boost and boost-devel are installed run the following commands:
* <code>export LD_LIBRARY_PATH</code>
+
<pre>
and now you will be able to sucessfully run your programs.
+
rpm -qi boost
 +
rpm -qi boost-devel
 +
</pre>
 +
 
 +
'''NOTE:''' These versions may be very old, they won't be upgraded or maintained by SHARCNET staff unless something in the operating system requires it to be upgraded. You are therefore '''strongly encouraged''' to use the SHARCNET-provided Boost modules discussed earlier on this page.
  
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==
 
==References==

Revision as of 16:22, 24 January 2015

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


SHARCNET-Provided Boost Modules

Which Versions of Boost are Available?

SHARCNET has a number of Boost versions available as special modules. The available versions can be viewed by running:

module avail boost

and/or by viewing the BOOST software page in the web portal.

At the present time, when you look up the available boost modules you will see output such as:

$ module avail boost

------------------------------------ /opt/sharcnet/modules -------------------------------------
boost/gcc482-openmpi183/1.50.0  boost/intel12-openmpi162/1.50.0
boost/gcc482-openmpi183/1.53.0  boost/intel12-openmpi162/1.53.0
boost/gcc482-openmpi183/1.55.0  boost/intel12-openmpi162/1.55.0
boost/gcc482-openmpi183/1.57.0  boost/intel12-openmpi162/1.57.0
boost/intel/1.55.0              boost/intel15-noopenmpi/1.57.0

------------------------------------ /opt/sharcnet/modules -------------------------------------
boost/gcc482-openmpi183/1.50.0  boost/intel12-openmpi162/1.50.0
boost/gcc482-openmpi183/1.53.0  boost/intel12-openmpi162/1.53.0
boost/gcc482-openmpi183/1.55.0  boost/intel12-openmpi162/1.55.0
boost/gcc482-openmpi183/1.57.0  boost/intel12-openmpi162/1.57.0
boost/intel/1.55.0              boost/intel15-noopenmpi/1.57.0
$

i.e., the following versions of Boost are available:

  1. Boost versions 1.50, 1.53, 1.55, and 1.57 for GCC v4.8.2 and OpenMPI v1.8.3
  2. Boost versions 1.50, 1.53, 1.55, and 1.57 for Intel v12 and OpenMPI v1.6.2
  3. Boost version 1.57 for Intel v15 without OpenMPI features (i.e., the "noopenmpi" item).

NOTE: The boost/intel/1.55.0 module should not be used --it is older and will be removed in the near future. Use one of the other Boost modules instead.

All of the aforementioned versions of Boost have been built with the operating system's installed Python. You can see which version of Python it will use by running:

rpm -qi python

NOTE: If you need a specific version of Boost compiled for a specific C++ compiler, version of OpenMPI, and/or a specific version of Python, then submit a ticket requesting such. Be sure to mention all required software packages and which versions are needed.


Using a Specific Version of Boost

To use a specific version of Boost, do the following:

  • Unload any loaded OpenMPI modules that will conflict.
  • Unload any loaded C++ compiler modules that will conflict.
  • Load any required C++ and OpenMPI modules.
  • Load the required version of Boost.

e.g.,

$ module list                                 # View which modules are currently loaded
$ module unload openmpi/intel/1.6.2           # Unload the OpenMPI (for Intel)
$ module unload intel/12.1.3                  # Unload the Intel C++ compiler
$ module load gcc/4.8.2                       # Load GCC v4.8.2
$ module load openmpi/gcc/1.8.3               # Load OpenMPI (for GCC)
$ module load boost/gcc482-openmpi183/1.57.0  # Load Boost v1.57 for GCC 4.8.2 and OpenMPI v1.8.3

Once this is done, you may use Boost (e.g., write #include <boost/filesystem.hpp> in your code, etc.). No special compiler options will be required.


If Special Compiler Options are Required

If you are not having success building your code using Boost (e.g., in a Makefile), you might need to manually specify the INCLUDE and LIB directories. You can get these paths by running the following command (replacing the full Boost module name with the one you've loaded), e.g.,

$ module show boost/gcc482-openmpi183/1.57.0
-------------------------------------------------------------------
/opt/sharcnet/modules/boost/gcc482-openmpi183/1.57.0:

module-whatis    Provides boost 1.57.0 (flavor gcc482-openmpi183) built using gcc/4.8.2, openmpi/gcc/1.8.3 on centos64.
conflict         intel
conflict         pgi
conflict         python
prereq   gcc/4.8.2
prereq   openmpi/gcc/1.8.3
prepend-path     --delim   CPPFLAGS -I/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/include
prepend-path     --delim   LDFLAGS -L/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/lib
prepend-path     LD_RUN_PATH /opt/sharcnet/boost/1.57.0/gcc482-openmpi183/lib
-------------------------------------------------------------------

$

The options you need to pass to the C++ compiler / linker follow CPPFLAGS and LDFLAGS in the above output, i.e., you will need to add these two options to your C++ compiler's command line:

  • -I/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/include
  • -L/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/lib


Operating System Installed Boost

If you don't load any SHARCNET-provided Boost module, you will be using the operating system's installed version of Boost. To determine which version(s) of boost and boost-devel are installed run the following commands:

rpm -qi boost
rpm -qi boost-devel

NOTE: These versions may be very old, they won't be upgraded or maintained by SHARCNET staff unless something in the operating system requires it to be upgraded. You are therefore strongly encouraged to use the SHARCNET-provided Boost modules discussed earlier on this page.


References

o Boost Homepage
http://www.boost.org/