Included here are my instructions which detail one way of compiling and installing the Boost libraries onto a Linux system. This information was tested on RedHat 7.3 and 8.0 systems. In the case of RedHat 7.3, the compiler was upgraded to gcc 3.2. RedHat 8.0 comes with gcc 3.2, therefore no compiler upgrade was necessary.
Download: go to the boost website and click on the "Download" link. Download the latest *.tar.gz tarball (I usually put tarballs in a local directory called /usr/src/tarballs). In my case the latest tarball was boost_1_29_0.tar.gz.
Unpack: make a directory somewhere (say /usr/src/devel), cd to that directory, and unpack the Boost tarball:
[trevor]$ gzip -d < /usr/src/tarballs/boost_1_29_0.tar.gz | tar xf -
|
Update Your Compiler: (if necessary) make sure to update your compiler. I used gcc 3.2 and found that it worked well.
Make Jam: yes that's right! Go out, pick some fresh berries, and make some jam, you need a break... Seriously, the utility that is used to build the library is a platform-independent tool called jam. You'll need to create this tool before we can build the library itself.
From where you've just unpacked the sources, cd to the directory boost_1_29_0/tools/build/jam_src. Typing make on the command-line should be all you need.
If the build went okay you'll find the executables in a subdirectory called (something along the lines of) bin.linuxx86. Simply become root and cp these files to somewhere appropriate, like /usr/local/bin (of course make sure /usr/local/bin is in your path, and of course you don't need the *.o files nor the *.a file).
Build The Library: now go back to the base directory of the Boost library (i.e. (in this case) boost_1_29_0). From here execute:
[trevor]$ bjam -sTOOLS=gcc
|
Install the Headers: the majority of the "code" for the Boost library is contained in its header files. Therefore all that is needed to take advantage of most of the functionality of Boost is to simply put the Boost header files somewhere where your compiler can find them.
Personally I like to put things I build into a place all on its own and then make symlinks to everything. Then, in the future, if/when a new version of Boost comes out, all that I need to do is to break and recreate one symlink. Following through along these lines I create a directory /usr/local/packages/boost-1.29.0 and then do a:
[root]# cp -a ${base}/boost/* /usr/local/packages/boost-1.29.0/include
|
[root]# ln -s boost-1.29.0 boost
|
With that in place I can now go to /usr/local/include and do a:
[root]# ln -s ../packages/boost/include/ boost
|
#include <boost/thread/thread.hpp>
|
The rational behind this is: if/when a new version of Boost comes out, say boost-1.29.1, then all I have to do is copy its header files to /usr/local/packages/boost-1.29.1/include and then go to /usr/local/packages, remove the existing link called boost and re-point it to boost-1.29.1 (instead of where it's currently pointing to, which is boost-1.29.0).
If you like this idea then you might want to check out the GNU stow package. |
Install the Libraries: since most of the code you need for the library is actually contained in the header files, having installed the header files, you already have most of what you need to start working with Boost. However, there are a handful of libraries that actually get built and need to be installed; you can find out which ones by looking at the contents of Jamfile at the base of the Boost sources.
In the case with this specific version of Boost the parts that create libraries are: python, regex, signals, test, and threads. What we need to do is to go into those build directories and copy the library files we find to some, more convenient location. (Don't forget to do a cp -a instead of just a plain cp so that the symlinks are maintained).
Following the example of what was done with the header files, I copied all the libraries I found to /usr/local/packages/boost-1.29.0/lib. I then go to /usr/local/lib and do a:
[root]# ln -s ../packages/boost/lib/* .
|