Boost Installation Howto (1.39 and newer)
Contents
These instructions are for 1.39 and newer. Installing an older version?
If you are using Ubuntu Karmic, please see this bug report. As of 2009-11-04, you need to use a Boost SVN checkout. If you are seeing errors like AttributeError: 'Boost.Python.StaticProperty' object attribute '__doc__' is read-only, you are affected by this issue.
Step 1: Install Boost
You may install via your operating system's package manager or from source.
From Source
These instructions will help you install the Boost C++ libraries on a Unix-like system. If you already have them installed, make sure that it's the version required by the software you would like to use. If not, no problem, we'll build it now.
On Linux, make sure you have the Python headers (i.e. development information) installed. Your operating system may call this package something like python-dev or python-devel.
Next, download the boost release tar.bz2 file. To untar the file, use tar xfj boost_1_39_0.tar.bz2.
On OS X, you may have to modify a couple of files to build Boost.Python properly. See https://svn.boost.org/trac/boost/ticket/3930.
Then, do this from the boost download directory:
$ ./bootstrap.sh --prefix=$HOME/pool --libdir=$HOME/pool/lib --with-libraries=signals,thread,python $ ./bjam variant=release link=shared install
A few notes:
You may omit --with-libraries=... if you want to build all of boost, but it will make the compile take somewhat longer.
Whenever you see a line beginning with the "$" dollar sign, this means you should enter the subsequent text at your shell prompt. You don't have to be root. If a command is marked with "sudo", these do require root privileges if you are using a Python interpreter that is installed globally.)
Please make sure that the Boost.Python configuration process finds the version of Python you intend to use. It is output during the configure/make stage. - You may adapt the file and directory names to suit your liking, however the rest of this tutorial will assume that you use these paths.
- Even though the lines may appear wrapped above, you need to type the commands all on one line.
Using a Mac with Snow Leopard and building for PyCUDA?
Since CUDA is 32-bit-only, boost needs to be built to match. On a Snow Leopard Mac, replace the boostrap and bjam commands with:
$ ./bootstrap.sh --prefix=$HOME/pool --libdir=$HOME/pool/lib --with-libraries=signals,thread,python $ ./bjam address-model=32_64 architecture=x86 variant=release link=shared install
The architecture setting comes from http://old.nabble.com/Boost-on-Snow-Leopard-failing-to-build-32-bit-target-td25218466.html and is the key to not getting "the architecture is invalid" error when running PyCuda's tests.
Using a multiprocessor machine?
If you have a multiprocessor machine, you may want to use
$ ./bjam -j4 variant=release link=shared install
instead of the last command. (Replace the "4" by your processor count.)
Potential Problems
Missing Compression Libraries
If you see something like:
...failed updating 30 targets... ...skipped 2 targets...
at the end of the build process, please double-check that you have the Python headers installed. If you failed fewer targets (up to 5), you're probably ok for most of my packages, but you might still want to install libz-dev and libbz2-dev for that "perfect score".
Broken libdir configuration
If you see something like
common.copy /lib/libboost_math_c99f-gcc43-mt-1_39.so.1.39.0
cp: cannot create regular file `/lib/libboost_math_c99f-gcc43-mt-1_39.so.1.39.0': Permission denied
cp "bin.v2/libs/math/build/gcc-4.3.3/release/threading-multi/libboost_math_c99f-gcc43-mt-1_39.so.1.39.0" "/lib/libboost_math_c99f-gcc43-mt-1_39.so.1.39.0"
...failed common.copy /lib/libboost_math_c99f-gcc43-mt-1_39.so.1.39.0...
...skipped <p/lib>libboost_math_c99f-gcc43-mt-1_39.so for lack of <p/lib>libboost_math_c99f-gcc43-mt-1_39.so.1.39.0...
...skipped <p/lib>libboost_math_c99f-gcc43-mt.so for lack of <p/lib>libboost_math_c99f-gcc43-mt-1_39.so.1.39.0...a broken project-config.jam may be at fault. When I ran bootstrap.sh, it did generate a broken project-config.jam--it used
option.set libdir : /lib ;
instead of
option.set libdir : /home/andreas/pool/lib ;
Fortunately, that's easily fixed.
This bug has been reported here: http://www.nabble.com/-Boost--Boost-1.39:-libdir-installation-path-problem-td23353816.html
Error: /bin/sh: g++: not found
Even though you might have followed the instruction from How to install Hedge from Git and installed (Debian/Ubuntu package g++-4.3), you might have forgotten to check if you installed the basic g++ package. To check this type
aptitude show g++ | grep State:
If it says
State: not installed
please install it via
sudo apt-get install g++
It seems obvious that you have installed g++ if you installed the package g++-4.3, but it is not true. Thus you have to take care of this!
Step 2: Tell the Dynamic Linker about Boost
If you use a bash or /bin/sh or another POSIX-compliant shell, use this command:
export LD_LIBRARY_PATH=$HOME/pool/lib:${LD_LIBRARY_PATH}or, if you are still using a C Shell, use this:
setenv LD_LIBRARY_PATH $HOME/pool/lib:${LD_LIBRARY_PATH}You might want to put this command in your startup script, so you don't have to type this over and over. If you forget this step, you will see errors like this one later on::
...gibberish... ImportError: libboost_python-gcc42-mt-1_39.so.1.39.0: cannot open shared object file: No such file or directory ...gibberish...
On OS X, LD_LIBRARY_PATH is spelled DYLD_LIBRARY_PATH.
Building with MPI
Note: The code hedge uses mpi4py now, and this step is not necessary any more to use hedge with MPI.
Add
using mpi ;
to project-config.jam. (And no, don't omit any spaces from that line)
Using a specific compiler
Add
using gcc : : gcc4 ;
to project-config.jam. (Again, don't omit any spaces from that line)
Using a specific Python installation
Add/modify the line
using python : 2.5 : /usr ;
in project-config.jam to suit your system and your preference.
Deleting an old version
Before you install a new version of Boost make sure to delete your old version. This includes all files of Boost in your $HOME/pool folder as well. Boost is in the lib and include subdirectories.
Installing from SVN
You can get the development version of Boost using
svn co http://svn.boost.org/svn/boost/trunk boost-trunk
Once the code is successfully checked out, proceed as above.
