---
title: C++
slug: v4-7/get-started/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.

:::hint{type="info"}
For a complete overview of the platforms, transports, and devices the C# SDK supports, select **C++&#x20;**&#x66;rom the [Directory of Compatibility Maps](docId\:BXAcGIchVBJo0XIb1_lxl).
:::

:::hint{type="info"}
For the API reference, see [Ditto 4.7.1 API Reference Documentation](https://software.ditto.live/cpp/Ditto/4.7.1/api-reference/).
:::

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

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.7.4/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
```

Linux aarch64

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

# 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\:QUixNdDWPh9RulXgZ8HKe).

*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) {
}
```

