Skip to content
Andrey Vukolov edited this page Jun 6, 2025 · 52 revisions

POSIX (Linux, MacOS, MSYS2)

Build Tools

Build tools requirements are:

  • GCC 5.2+ / Clang / MinGW / MSVC
  • GNU Autotools / CMake / Meson

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

Build dependencies

Library Required Version Description
msgpack-c 1.3+ Data serialization engine
libgnutls 3.3+ Cryptography
libnettle 2.4+ Included as explicit GnuTLS dependency
libargon2 Key stretching engine
libreadline Optional dependency for DHT tools
jsoncpp 1.7.4-3+ Data exchange for Peer Discovery
cython 0.29.31+ Optional dependency for Python bindings (does not work in outdated Ubuntu distribution)
libfmt Log formatting, used as optional dependency for Peer Discovery
restinio 0.5.1.2 Optional dependency - REST API controller

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

Debian/Ubuntu

Ubuntu 22.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.

Windows

Work in progress: see https://github.com/savoirfairelinux/opendht/pull/750

Clone this wiki locally