Boost is portable C++ source libraries and work well with the C++ Standard Library. It is intended to be widely useful and usable across a broad spectrum of applications.
In this article, we will discuss about how to install Boost Library within Linux. The method we use here is generic way, which means, it can be applied to any Linux distribution. However, for demonstration I will use following:
- Slackware64 14.0 Linux
- GCC (Compiler)
At least you have privileges for installing the files later.
Obtain the Materials
Boost Library has official site here.
The latest version of Boost library is version 1.53.0 which can be downloaded from sourceforge (here). While there is also Boost 1.54.0 beta available, we will use the stable version at this time.
Compile & Install
Assuming the archive is boost_1_53_0.tar.bz2 and on path ~/Downloads or /home/user/Downloads. First we have to extract the library from the archive.
cd ~/Downloads tar -xjf boost_1_53_0.bz2 cd boost_1_53_0.bz2
Next, build bjam binary and also set some options on what to compile and where to.
Boost is a collection of libraries / modules. The whole Boost libraries will cost some time and computation for compilation. We can skip some libraries we don’t want or won’t use. To see the list of libraries need compiling, run following:
For example, following is the result / the list of libraries on Boost 1.53.0:
Pick any modules you want to include in Boost, for example: filesystem,program_options, and system. In this case, we can use argument –with-library=filesystem,program_options,system to bootstrap.sh. However you can also pick all / compile all the libraries, just invoke ./bootstrap.sh without –with-library switch.
Next, choose where the library will be installed. By default, the header files will be installed to /usr/local/include and the libraries (.so, .a) will be installed to /usr/local/lib. If other path is preferred, we can use –libdir switch for specifying where library will be stored and –includedir switch for specifying where header will be stored.
Now bring all of the info and invoke like this:
./bootstrap.sh --libdir=/usr/local/lib64 --includedir=/usr/local/include
And you could see I will build all the libraries and store the library to /usr/local/include.
Now let’s build the library
Then install by (make sure you have privileges to do)
At this point we have successfully installed Boost libraryc++, linux