To integrate Ditto with your app:

  1. Add a reference to the Ditto static library in your project’s build configuration settings. (Installing Ditto
  2. Add a linker flag to the Ditto static library in your project’s build configuration settings. (Linking Your App to Ditto)
  3. Add Ditto to your C++ code and initiate data sync. (Initializing Ditto)
curl -O https://software.ditto.live/cpp-linux-x86_64/Ditto/4.3.0/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz

Installing Ditto

Install the SDK’s libditto.astatic library and Ditto.h header files by downloading and extracting Ditto.tar.gz in your project’s ./sdk/ directory:

Linking Your App to Ditto

Configure your app to link your C++ code to the Ditto static library at compilation time by doing either of the following as appropriate:

If developing for Linux, create the executable file in the ./dist directory from your main.cpp file and add the -lditto linker flag to your project’s build configuration settings:

Linux
g++ -std=c++17 ./src/main.cpp -I ./sdk -lditto -ldl -lrt -pthread -L ./sdk -o dist/main;

Initializing Ditto

Finish integrating Ditto with your app by establishing an identity for your app, initializing Ditto, setting up the minimum log level for debugging, and starting the data sync process with the Ditto backend:

C++
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) {
}