Installation
- 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.
For linux systems running on Intel-based CPUs with x86_64
architecture.
curl -O https://software.ditto.live/cpp-linux-x86_64/Ditto/4.8.1-rc.1/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
For linux systems running on ARM64-based CPUs with aarch64
architecture.
curl -O https://software.ditto.live/cpp-linux-aarch64/Ditto/4.8.1-rc.1/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
This iOS static library is "fat", containing slices for the following CPU archtectures: x86_64
, arm64
curl -O https://software.ditto.live/cpp-ios/Ditto/4.8.1-rc.1/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
- 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.
- 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
- Notice we've added a
-framework Security,CoreFoundation,CoreBluetooth,ObjC
, this will enable the C++ SDK to leverage iOS peer to peer networks.
g++ -std=c++17 ./src/main.cpp -I ./sdk -lditto -ldl -framework Security,CoreFoundation,CoreBluetooth,ObjC -pthread -L ./sdk -o dist/main;
warning
Coming soon.
C++ is not currently supported on Windows.
- 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) {}