Skip to content
Filipp Ozinov edited this page Oct 19, 2020 · 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.

if OPENDHT_PROXY_HTTP_PARSER_FORK is On, build with https://github.com/binarytrails/http_parser/archive/v2.9.3.tar.gz

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/2c0b6f5e5ba04d7a74e8406a3df1fd433680599d.tar.gz \
    && ls -l && tar -xzf 2c0b6f5e5ba04d7a74e8406a3df1fd433680599d.tar.gz \
    && cd restinio-2c0b6f5e5ba04d7a74e8406a3df1fd433680599d/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

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

# Dependencies for proxy server/client:
# libasio-dev (1.10) is too old
wget https://github.com/aberaud/asio/archive/a7d66ef4017d8f1b7f2cef1bb4ba8e23b0961571.tar.gz \
    && tar -xvf a7d66ef4017d8f1b7f2cef1bb4ba8e23b0961571.tar.gz && cd asio-a7d66ef4017d8f1b7f2cef1bb4ba8e23b0961571/asio \
    && ./autogen.sh && ./configure --prefix=/usr --without-boost --disable-examples --disable-tests  \
    && make install \
    && cd ../../ && rm -rf asio*

# Build & install restinio
mkdir restinio && cd restinio \
    && wget https://github.com/aberaud/restinio/archive/2c0b6f5e5ba04d7a74e8406a3df1fd433680599d.tar.gz \
    && ls -l && tar -xzf 2c0b6f5e5ba04d7a74e8406a3df1fd433680599d.tar.gz \
    && cd restinio-2c0b6f5e5ba04d7a74e8406a3df1fd433680599d/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
# Install python binding dependencies
sudo dnf install python3-Cython python3-devel redhat-rpm-config

macOS

brew install gnutls msgpack
brew install 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.

Clone this wiki locally