Skip to content

Installation of dependencies

Rei edited this page Apr 4, 2020 · 6 revisions

This project is tested on Ubuntu (18.04) and macOS (10.15). It is expected to run on Linux distributions, e.g., CentOS, without much trouble. The implementation of the code has so far never given any consideration to Windows operating systems. Thus, it is not expected to work on Windows without substantial additional work.

The implementation of this project is written in C++ 17.

  • C/C++ compiler and library

    • gcc version 8 or up on Linux. We recommend clang version 8 or up as an alternative (or better) compiler. Note: the llvm libc++ lacks the support of some C++ 17 features, thus still need the gcc library.

    • Apple LLVM version 11.0.0 (clang-1100.0.33.8) provided by XCode 11 on macOS

  • cmake version 3.15 or up

This project builds on several existing projects:

An installation script sys-dep-install.sh is provided in the folder ci for Ubuntu 18.04 and macOS 10.15.

Basic tools via system installation

The following are instructions for Ubuntu and macOS.

Ubuntu 18.04

  1. Install some basics build tools

    sudo apt-get install autoconf libtool pkg-config
  2. Install gcc-8

    sudo apt-get install gcc-8 g++-8

    Update alternatives

    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 100
  3. Install clang-9

    Add repository. If you have a different version of Ubuntu other than 18.04, see https://apt.llvm.org for corresponding repos.

    wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
    sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main"
    sudo apt-get update 
    sudo apt-get install clang-9

    Update alternatives

    sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-9 100
    sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-9 100
  4. (Optional) for libsecp256k1

    sudo apt-get install libgmp-dev

macOS 10.15

  1. XCode11

    xcode-select --install

    Apple provides its own C/C++ compiler and lib via XCode, Apple clang version 11.0.0 (clang-1100.0.33.8). macOS must upgrade to 10.15.

  2. Brew

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. Some configure/make tools

    brew install automake autoconf libtool
    
  4. (Optional) for libsecp256k1

    brew install gmp
    

Dependencies installation from source

Some dependencies need to be installed from the source. The following is the detailed instruction, with slight variation depending on Linux or macOS.

CMake

macOS:

brew install cmake
# version 3.17 will be installed

Linux:

git clone -b v3.17.0 --single-branch https://github.com/Kitware/CMake.git
cd CMake
./bootstrap && make -j && sudo make install

OpenSSL

macOS:

brew install openssl@1.1
# The following is needed for libevent install
export OPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1"

Linux:

git clone -b OpenSSL_1_1_1f https://github.com/openssl/openssl.git
cd openssl
./config && make -j && sudo make install

This is required by libevent and secp256k1.

Protocol Buffers

macOS:

brew install protobuf
# version 3.11.4 will be installed

Linux:

git clone -b v3.11.4 --single-branch https://github.com/protocolbuffers/protobuf.git
cd protobuf
git submodule update --init --recursive
./autogen.sh && ./configure && make -j
make check
sudo make install
sudo ldconfig # refresh shared library cache.

If "make check" fails, you can still install, but it is likely that some features of this library will not work correctly on your system. Proceed at your own risk. https://github.com/protocolbuffers/protobuf/blob/master/src/README.md

gRPC

macOS:

brew install grpc
# version 1.24.3 will be installed

Linux:

git clone -b v1.28.1 --single-branch https://github.com/grpc/grpc.git
cd grpc
git submodule update --init
make -j
sudo make install

The above instruction is from https://github.com/grpc/grpc/blob/master/BUILDING.md.

RocksDB

macOS:

brew install rocksdb
# version 6.7.3 will be installed

Linux:

git clone -b v6.7.3 --single-branch https://github.com/facebook/rocksdb.git
cd rocksdb
make shared_lib -j
sudo make install

libevent

git clone -b release-2.1.11-stable --single-branch https://github.com/libevent/libevent.git
cd libevent
mkdir build && cd build
cmake ..
make -j && sudo make install

The brew-installed libevent (version 2.1.11_1) on macOS does not work smoothly for now. So please compile as instructed in the above.

Google Test

git clone -b release-1.10.0 --single-branch https://github.com/google/googletest.git
cd googletest && mkdir build && cd build
cmake ..
make -j && sudo make install

Secp256k1

git clone https://github.com/bitcoin-core/secp256k1.git
cd secp256k1
./autogen.sh && ./configure --enable-module-recovery=yes
make -j && sudo make install