Skip to main content

Installation

  1. To start integrating Ditto into your app you need to download a copy of the libditto.a static library and the Ditto.h header. The following command will download and then unpack an archive containing the library and header. The URL in the following command will download a copy of the static library built to work on iOS:
curl -O https://software.ditto.live/cpp-ios/Ditto/4.1.1/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz

If you want to download the C++ SDK for usage on Linux x86_64 then use the following command, which uses a different URL:

curl -O https://software.ditto.live/cpp-linux-x86_64/Ditto/4.1.1/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
  1. Configure your app to link to the Ditto static library. Usually, this will mean adding an -lditto to a compilation step for your app.
  • Assume we have unzipped the Ditto.tar.gz in a relative directory ./sdk/
  • main code entry point is in ./src/main.cpp
  • output will be in ./dist/main
g++ -std=c++17 ./src/main.cpp -I ./sdk -lditto -ldl -lrt -pthread -L ./sdk -o dist/main;

To add Bluetooth Low Energy capabilities please follow the instructions here.

  1. Now, in your C++ code, you can import ditto with: #include <Ditto.h>
auto identity =    Identity::OnlinePlayground("REPLACE_ME_WITH_YOUR_APP_ID",                               "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN", true);try {  Ditto ditto = Ditto(identity, dir);  ditto.set_minimum_log_level(LogLevel::debug);  ditto.start_sync();} catch (const DittoError &err) {}