How to Compile and Install Boost Libraries on Linux

Posted by ldb358 on Thu, 16 May 2019 20:02:36 +0200

Preface

When compiling a bitcoin wallet, you need to rely on the Boost library. Because it takes a long time to compile and wastes a lot of time in "give it a try", write down the successful process.

Download the Boost installation package

  • Download via wget tool
wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz

Anyway, I didn't download it successfully~

  • Manually download installation packages
    Download to local location and upload to server at above address

decompression

[root@bogon software]# tar zxvf boost_1_64_0.tar.gz

Compile and Install

Enter the extracted directory first:

[root@bogon software]# cd boost_1_64_0

Then run the bootstrap.sh script and set the parameters:

[root@bogon boost_1_64_0]# ./bootstrap.sh --with-libraries=all --with-toolset=gcc

--with-libraries specifies which boost libraries to compile. All is to compile all. Write the names of the libraries if you only want to compile some of them, separated by a sign. There are several libraries you can specify:

Library Name Explain
    atomic
    chrono
    context
    coroutine
    date_time
    exception
    filesystem
    graph
Graph Components and Algorithms
    graph_parallel
    iostreams
    locale
    log
    math
    mpi
Metaprogramming Framework Implemented by Templates
    program_options
    python
Mapping C++ classes and functions into Python
    random
    regex
Regular Expression Library
    serialization
    signals
    system
    test
    thread
Portable C++ Multithreaded Library
    timer
    wave

--with-toolset specifies which compiler to use at compilation time, GCC is sufficient on Linux. If you have multiple versions of GCC installed on your system, you can specify the version of GCC here, for example--with-toolset=gcc-4.4

When the command is executed, it is successful to see the following:

Building Boost.Build engine with toolset gcc... tools/build/src/engine/bin.linuxx86_64/b2
Detecting Python version... 2.6
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...

Bootstrapping is done. To build, run:

    ./b2

To adjust configuration, edit 'project-config.jam'.
Further information:

   - Command line help:
     ./b2 --help

   - Getting started guide: 
     http://www.boost.org/more/getting_started/unix-variants.html

   - Boost.Build documentation:
     http://www.boost.org/build/doc/html/index.html

Start compiling boost by executing the following command:

[root@bogon boost_1_64_0]# ./b2 toolset=gcc

The compilation takes about 10 minutes, wait patiently, and the following tips will follow at the end:

ln-UNIX stage/lib/libboost_wave.so
...failed updating 56 targets...
...skipped 6 targets...
...updated 1081 targets...

Finally, execute the following command to start installing boost:

[root@bogon boost_1_64_0]# ./b2 install --prefix=/usr

--prefix=/usr is used to specify the boost installation directory. Without this parameter, the default header file is in the / usr/local/include/boost directory and the library file is in the / usr/local/lib/directory.If you specify the installation directory as--prefix=/usr, boost will be installed directly into the system header and library files directories, omitting the configuration environment variables.

The following tips will appear after installation:

...failed updating 56 targets...
...skipped 6 targets...
...updated 13610 targets...

Finally, note that if you want to compile with the boost library immediately after installation, you also need to execute this command:

[root@bogon boost_1_64_0]# ldconfig

Update the dynamic link library of the system.

Compile the Bitcoin wallet again.

Topics: Python Unix Linux