Tuesday, December 30, 2014

How to install the latest Boost C++ Library on Linux (Ubuntu)

Usually, the Boost C++ Library installable from the Ubuntu Software Center or apt (Advanced Package Tool) is NOT the latest one.
If you want to use the latest version the Boost C++ Library, you can do so by installing the library on your home directory ($HOME).
The procedure is:

1. Download the latest source code from the Boost C++ website (http://www.boost.org/). more
2. Upload the downloaded file to the Linux (Ubuntu) server. more
3. tar xvzf [downloaded file] more
4. cd [created directory] more
5. ./bootstrap.sh --prefix=[path to the home directory] more
6. ./b2 install more

To check if the installation is correctly done, you can compile & run a test program from the Boost C++ library website. more
When compiling the test program with g++, be sure to set the header search path option (-I) and the library search path option (-L) to where the library is installed.
Because we installed the library to the home directory, we should use -I $HOME/include and –L $HOME/lib. more
Finally, the environment variable LD_LIBRARY_PATH should be modified to include $HOME/lib, to dynamically link the shared objects. more