How to Install Boost Development Libraries (boost-devel) on CentOS 6.3: A Comprehensive Guide


3 views

When working with CentOS 6.3, you'll notice that Boost libraries follow a slightly different naming pattern than what you might expect. The correct package name is boost-devel, not libboost-devel which is more common in some other distributions.

yum search boost | grep devel
boost-devel.x86_64 : Boost C++ Libraries development files

There are several approaches to get Boost development libraries installed on CentOS 6.3:

Method 1: Using YUM Repository

The most straightforward way is through the default repositories:

sudo yum install boost-devel

This will install the default version available in CentOS 6.3 repositories (typically Boost 1.41).

Method 2: EPEL Repository

For newer versions, you can enable the EPEL repository:

sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum install boost-devel

Method 3: Manual Compilation

If you need a specific version not available in repositories:

wget https://sourceforge.net/projects/boost/files/boost/1.54.0/boost_1_54_0.tar.gz
tar xzf boost_1_54_0.tar.gz
cd boost_1_54_0
./bootstrap.sh --prefix=/usr/local
sudo ./b2 install

After installation, verify the headers and libraries are properly installed:

ls /usr/include/boost/version.hpp
ls /usr/lib64/libboost_*

Or create a simple test program:

#include 
#include 

int main() {
    std::cout << "Boost version: " 
              << BOOST_VERSION / 100000 << "." 
              << BOOST_VERSION / 100 % 1000 << "." 
              << BOOST_VERSION % 100 
              << std::endl;
    return 0;
}

Some Boost components may require additional packages. For example, to use Boost.Python:

sudo yum install boost-python

Or for Boost.Thread:

sudo yum install boost-thread

If you encounter linking errors, ensure you're using the correct compiler flags:

g++ -I/usr/include/boost my_program.cpp -lboost_system -lboost_filesystem

For version conflicts when manually compiling, consider using environment modules or updating your LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

For modern development on CentOS 6.3, consider using Software Collections:

sudo yum install centos-release-scl
sudo yum install devtoolset-8
scl enable devtoolset-8 bash
yum install boost-devel

The first thing to understand is that package names differ between Linux distributions. What's called libboost-devel in some distros might have a different naming pattern in CentOS/RHEL.

Before installation, let's search for available Boost packages:

yum search boost | grep -i devel

This should return results like:

boost-devel.x86_64 : Boost C++ Libraries development files
boost141-devel.x86_64 : Boost 1.41 C++ Libraries development files

For CentOS 6.3, the standard package is:

sudo yum install boost-devel

This will install the default Boost version available in CentOS 6.3 repositories (likely 1.41 or similar).

After installation, verify the headers and libraries:

ls /usr/include/boost
ls /usr/lib64/libboost_*

If you need a specific version, you might need to:

  1. Enable EPEL repository:
    sudo yum install epel-release
  2. Install alternative versions:
    sudo yum install boost148-devel

Create a test file boost_test.cpp:

#include <boost/version.hpp>
#include <iostream>

int main() {
    std::cout << "Boost version: " 
              << BOOST_VERSION / 100000     << "."  // major version
              << BOOST_VERSION / 100 % 1000 << "."  // minor version
              << BOOST_VERSION % 100                // patch level
              << std::endl;
    return 0;
}

Compile and run:

g++ boost_test.cpp -o boost_test
./boost_test

If the repository versions don't meet your requirements:

  • Build from source (get the tarball from boost.org)
  • Consider using a package manager like Conan
  • Use a third-party repository like IUS

Problem: Missing dependencies
Solution: Install required components first:

sudo yum install gcc-c++ python-devel bzip2-devel

Problem: Version conflicts
Solution: Use alternatives system or environment modules to manage multiple versions.