简体   繁体   中英

How to install Boost from source

I am trying to install the Boost C++ from source.

I first tried using yum to install them in (Amazon Linux AMI) but it installed a version that is too old. I need at least version 1.54

So I tried to follow the instructions here: https://www.boost.org/doc/libs/1_70_0/more/getting_started/unix-variants.html

Once I downloaded the source, I tried symlinking the header files to /usr/include:

ln -s /root/boost_1_70_0/boost /usr/include/boost

Then I followed the instructions to try to build:

cd /root/boost_1_70_0
./bootstrap.sh
./b2 install

Then when I try to compile my program that needs boost libraries (happens to be OSRM), I get this error:

make[2]: *** No rule to make target `/usr/lib64/libboost_date_time-mt.so', needed by `osrm-components'.  Stop.

So it seems somehow I need to build the boost .so files to go in /usr/lib64 . But how do I do that?

I believe that you've already built the boost .so files but I don't know where. It normally tries to install them in /usr/local , see section 5.1 of the instructions you referenced.

You may be able to find them with locate , eg:

 locate boost

Otherwise, you can call ./bootstrap.sh with a prefix indicating where you want it to build the libraries, eg:

./bootstrap.sh --prefix=/root/boost_1_70_0/stage
./b2 install

You can then copy the .so files together with with their symbolic links to /usr/lib64 , eg:

cd /usr/lib64
rm -fr libboost*
cp -a /root/boost_1_70_0/stage/lib/libboost* .
chmod a+x libboost*

Note: the line rm -fr libboost* in /usr/lib64 is to remove the very old version of boost that you installed with yum .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM