Skip to main content

Installation

C++ is currently only supported for iOS and Linux. We will publish binaries for Windows and macOS soon. Please let us know if these binaries are important for your timeline by emailing us at contact@ditto.live.

  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/1.1.9/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/1.1.9/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>
Ditto ditto;auto identity =    Identity::OnlinePlaygroundV2("REPLACE_ME_WITH_YOUR_APP_ID",                                 "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN");try {  ditto = Ditto(identity, dir);  ditto.try_start_sync();} catch (const DittoError &err) {}