Skip to content
Adrien Béraud edited this page Aug 27, 2023 · 47 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

  • restinio v.0.5.1.2, 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

Ubuntu 20.04+:

# Install OpenDHT dependencies
sudo apt install libncurses5-dev libreadline-dev nettle-dev libgnutls28-dev libargon2-0-dev libmsgpack-dev  libssl-dev libfmt-dev libjsoncpp-dev libhttp-parser-dev libasio-dev

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

# Build & install restinio (for proxy server/client):
mkdir restinio && cd restinio \
    && wget https://github.com/aberaud/restinio/archive/2224ffedef52cb2b74645d63d871d61dbd0f165e.tar.gz \
    && ls -l && tar -xzf 2224ffedef52cb2b74645d63d871d61dbd0f165e.tar.gz \
    && cd restinio-2224ffedef52cb2b74645d63d871d61dbd0f165e/dev \
    && cmake -DCMAKE_INSTALL_PREFIX=/usr -DRESTINIO_TEST=OFF -DRESTINIO_SAMPLE=OFF \
             -DRESTINIO_INSTALL_SAMPLES=OFF -DRESTINIO_BENCH=OFF -DRESTINIO_INSTALL_BENCHES=OFF \
             -DRESTINIO_FIND_DEPS=ON -DRESTINIO_ALLOW_SOBJECTIZER=Off -DRESTINIO_USE_BOOST_ASIO=none . \
    && make -j8 && make install \
    && cd ../../ && rm -rf restinio

Fedora

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

macOS

brew install gnutls msgpack-cxx argon2 asio

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.