---
title: C++
slug: v4-8/install-guides/cpp
icon: {"faIcon":"fa-brands fa-uikit"}
docTags: 
createdAt: 2023-08-03T04:37:40.707Z
---

You can integrate the Ditto SDK into C++ projects to develop for Linux and iOS platforms.

To install the C++ SDK:

::::WorkflowBlock
:::WorkflowBlockItem
Fetch and extract the Ditto package. ([Downloading and Unpacking Ditto](./#downloading-and-unpacking-ditto))&#x20;
:::

:::WorkflowBlockItem
Configure your app to link to the Ditto static library. ([Linking to Ditto](./#linking-to-ditto))
:::
::::

# Downloading and Unpacking Ditto

## Linux

Download `Ditto.tar.gz` and unpack an archive containing the `libditto.a` static library and `Ditto` header:

:::CodeblockTabs
Linux x86\_64

```curl
curl -O https://software.ditto.live/cpp-linux-x86_64/Ditto/4.8.2/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
```

Linux aarch64

```curl
curl -O https://software.ditto.live/cpp-linux-aarch64/Ditto/4.8.2/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
```
:::

## Android

The Ditto C++ SDK for Android is available in the Maven Central repository: [https://central.sonatype.com/artifact/live.ditto/ditto-cpp](https://central.sonatype.com/artifact/live.ditto/ditto-cpp)

# Linking to Ditto

Add `-lditto` as a compilation step in the `main.cpp` source file:&#x20;

:::hint{type="info"}
For instructions on adding cross-platform Bluetooth Low Energy (LE) capabilities, see [Bluetooth on Linux](docId\:GPnhy_1_KdnqAHpHCOXFi).

*BlueZ* is the official Bluetooth protocol stack implementation for Linux systems to communicate with other Bluetooth-enabled platforms.
:::

:::CodeblockTabs
Linux

```curl
# This command assumes:
# You have unzipped the Ditto.tar.gz in a relative directory ./sdk/
# Your main code entry point is in ./src/main.cpp

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

 # Once executed, your output will be available at: ./dist/main
```

iOS

```curl
#This command assumes:
# You have unzipped the Ditto.tar.gz in a relative directory ./sdk/
# Your main code entry point is in ./src/main.cpp

g++ -std=c++17 ./src/main.cpp -I ./sdk -lditto -ldl -framework Security,CoreFoundation,CoreBluetooth,ObjC -pthread -L ./sdk -o dist/main;

# Note: By adding the "-framework Security,CoreFoundation,CoreBluetooth,ObjC.," you enable the C++ SDK to leverage iOS peer-to-peer networks.
 
 # Once executed, your output will be available at: ./dist/main
```
:::

# Importing Ditto

From the source code of your app, using `#include <Ditto.h>`,  import Ditto and provide your access credentials:

```cpp
auto identity =
    Identity::OnlinePlayground("YOUR_APP_ID", "PLAYGROUND_TOKEN", true);
try {
  Ditto ditto = Ditto(identity, dir);
  ditto.set_minimum_log_level(LogLevel::debug);
  ditto.start_sync();
} catch (const DittoError &err) {
}
```

