Build the library

Adrien Béraud edited this page Jun 13, 2018 · 30 revisions

Install build tools

Build tools requirements are:

  • GCC 5.2+ or Clang/LLVM
  • Autotools or CMake

Build is currently tested on various GNU/Linux (including Ubuntu) and macOS.

Build dependencies

OpenDHT dependencies are:

  • msgpack-c 1.3+, used for data serialization.
  • GnuTLS 3.3+, used for cryptographic operations.
  • Nettle 2.4+, a GnuTLS dependency for crypto.
  • Argon2, a dependency for key stretching.
  • Readline, an optional dependency for the DHT tools.
  • Cython, an optional dependency for the Python bindings.

Optional dependencies

  • restbed 4.0+, used for the REST API.
  • jsoncpp 1.7.4-3+, used for the REST API.

Follow these instructions to install OpenDHT dependencies depending on your system:

Debian/Ubuntu

Msgpack-c is not packaged in Debian and Ubuntu (until 17.04) so it has to be built separately.

# Install GnuTLS 3, Readline and Nettle, Ubuntu 16.10+
sudo apt-get install libncurses5-dev libreadline-dev nettle-dev libgnutls28-dev
# Install GnuTLS 3, Readline and Nettle, Ubuntu 16.04
# sudo apt-get install libncurses5-dev libreadline-dev nettle-dev libgnutls-dev
# Install optional dependencies
# sudo apt-get install librestbed-dev libjsoncpp-dev

# Install Argon2, msgpack-c (Ubuntu 17.04+)
sudo apt install libargon2-0-dev libmsgpack-dev

# Install python binding dependencies
sudo apt-get install cython3 python3-dev python3-setuptools

# Build and install msgpack-c (Ubuntu 16.04 - 16.10)
sudo apt-get install build-essential cmake
wget https://github.com/msgpack/msgpack-c/releases/download/cpp-2.1.1/msgpack-2.1.1.tar.gz
tar -xzf msgpack-2.1.1.tar.gz
cd msgpack-2.1.1 && mkdir build && cd build
cmake -DMSGPACK_CXX11=ON -DMSGPACK_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install

Fedora

Msgpack-c 1.3+ is available since Fedora 23. For previous Fedora versions, refer to the above instructions for Ubuntu to install msgpack-c.

# Install GnuTLS, Readline and msgpack-c
sudo dnf install readline-devel gnutls-devel msgpack-devel
# Install python binding dependencies
sudo dnf install python3-Cython python3-devel redhat-rpm-config

macOS

brew install gnutls msgpack

Build

Using CMake

# clone the repo
git clone https://github.com/savoirfairelinux/opendht.git

# build and install
cd opendht
mkdir build && cd build
cmake -DOPENDHT_PYTHON=ON -DCMAKE_INSTALL_PREFIX=/usr ..
make -j4
sudo make install

Python bindings can be disabled by running cmake with -DOPENDHT_PYTHON=OFF instead of -DOPENDHT_PYTHON=ON.

DHT Tools can be disabled by running cmake with -DOPENDHT_BUILD_TOOLS=OFF.

The /usr install prefix is optional, it helps to build projects with OpenDHT without having to add /usr/local/lib in LD_LIBRARY_PATH.

The proxy server can be activated with -DOPENDHT_PROXY_SERVER=ON. The full API (with SIGNand ENCRYPT endpoints) can be activated with -DOPENDHT_PROXY_SERVER_IDENTITY=ON. The proxy client can be activated with -DOPENDHT_PROXY_CLIENT=ON and the push notifications support with -DOPENDHT_PUSH_NOTIFICATIONS=ON.

Using Autotools

# clone the repo
git clone https://github.com/savoirfairelinux/opendht.git

# build and install
cd opendht
./autogen.sh && ./configure --prefix=/usr
make
sudo make install

Python bindings can be disabled by running ./configure with the --disable-python argument.

DHT Tools can be disabled by running ./configure with the --disable-tools argument.

The proxy server can be activated by running ./configure with the --enable-proxy-server argument. The full API (with SIGNand ENCRYPT endpoints) can be activated with --enable-proxy-server-optionals. The proxy client can be activated by adding --enable-proxy-client and push notifications supports with --enable-push-notifications.

Installing in different root

Using either build method shown above, you can safely install OpenDHT in a diffrent root directory in the standard way like so:

make DESTDIR=${SOME_DIR} install

Note that ${SOME_DIR} must be an absolute path as stated in the GNU standards.