I have built and installed boost using the following steps:

# Boostrap and install
JOBS=`grep -c ^processor /proc/cpuinfo`
wget https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2
tar xf boost_1_67_0.tar.bz2
cd boost_1_63_0
./b2 -d1 -j${JOBS} --with-thread --with-filesystem --with-python --with-regex -sHAVE_ICU=1 --with-program_options --with-system link=shared release toolset=gcc stage
./b2 -d1 -j${JOBS} --with-thread --with-filesystem --with-python --with-regex -sHAVE_ICU=1 --with-program_options --with-system link=shared release toolset=gcc install
sudo bash -c "echo '/usr/local/lib' > /etc/ld.so.conf.d/boost.conf"
sudo ldconfig

Then, I try to build mapnik which uses boost. I checkout mapnik and run ./bootstrap.sh and ./configure. I get the error "Could not find required header or shared library for boost filesystem". The boost section of configure is as follows:

Searching for boost libs and headers... (cached) 
Found boost libs: mason_packages/.link/lib
Found boost headers: mason_packages/.link/include
Checking for C++ header file boost/version.hpp... yes
Checking for Boost version >= 1.61... yes
Found boost lib version... 
Checking for C++ library boost_system... no
Could not find required header or shared library for boost system
Checking for C++ library boost_filesystem... no
Could not find required header or shared library for boost filesystem
Checking for C++ library boost_regex... yes
Checking for C++ library boost_program_options... yes
ValueError: invalid literal for int() with base 10: '':
  File "/root/src/mapnik/SConstruct", line 1600:
    boost_version = [int(x) for x in env.get('BOOST_LIB_VERSION_FROM_HEADER').split('_')]

(Build steps courtesy of keisan)

Why doesn't the system find the boost library 1.67? I don't remember installing boost 1.63. I have compiled and installed 1.67, but the build system does not use it. Where does the system look for boost on the system? I deleted all libboost_* files in /usr/local/lib and /usr/lib64, but still don't know where the system looks for boost. Can someone give a tip on how to tell the system about the newly compiled software?


Cent OS 7 user here, also trying to get Mapnik to build with optional dependencies, however mine does (seem to) recognize my updated Boost build. You've probably already surpassed this problem, side-stepped it, or forgotten about it, but I mention this anyway in case it might help you or someone else.

From what I am reading, it's almost like Mapnik wants/needs dependencies to be built using the same compiler in order to recognize those dependencies during the make/install steps. However, if you use this approach, it actually creates an alternative, non-default compiler, which you have to specify in your shell session in order to use in place of the default compiler.

I used this approach to update my compiler, build Boost, then configure Mapnik. So it might work for you.

Important. Note specifically the export CC= and export CXX= instructions appearing in the second step. As this is where you override your default compiler, and it seems that most/all of the dependencies need to be built with this compiler.

First, get an updated gcc/g++ compiler from the gcc6 series with c++14 support:

## Instructions modified from here, I just changed the gcc version.. 
## https://linuxhostsupport.com/blog/how-to-install-gcc-on-centos-7/
cd /root/downloads
screen -U -S gcc
wget http://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-6.5.0/gcc-6.5.0.tar.gz
tar zxf gcc-6.5.0.tar.gz
cd gcc-6.5.0
## Install bzip2 if you don't have it yet..
yum install bzip2
## Install gcc prereqs..
./configure --disable-multilib --enable-languages=c,c++
make -j 4
make install

Next, build and install Boost from source. This approach may result in a second installation of Boost. But you need to know where it lands in order to specify it during Mapnik's config step:

## Create temporary links to the new gcc/g++ compiler resources.
## These disappear with your shell session but need to be in effect for both the Boost and Mapnik builds.
export CC=/usr/local/bin/gcc
export CXX=/usr/local/bin/g++

cd /root/downloads
wget https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz
tar -xzf boost_1_*
cd boost_1_*
## This prefix variable sets the install location for boost, knowing this location is important. 
## This was the location suggested by the instructions I followed, which I've lost, but this seems to be a standard alternative location.
./bootstrap.sh --prefix=/opt/boost
./b2 install --prefix=/opt/boost --with=all

Now Boost is installed and lives here: /opt/boost/

At this point, when building and installing Mapnik, you can specify your updated Boost version in the configure step, like below.

This is important— If you have rebooted, or if you have logged out and logged back in, you need to repeat the export CC= and export CXX= instructions that appear at the top of the second step in order to ensure Mapnik builds with the same compiler you used to build Boost!

./configure BOOST_LIBS=/opt/boost/lib BOOST_INCLUDES=/opt/boost/includes

Hopefully this helps someone!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.