> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ditto.live/llms.txt
> Use this file to discover all available pages before exploring further.

# C++

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

# Installing the C++ SDK

## Linux

To install the C++ SDK:

<Steps>
  <Step>
    Fetch and extract the Ditto package. ([Downloading and Unpacking Ditto](#downloading-and-unpacking-ditto))
  </Step>

  <Step>
    Configure your app to link to the Ditto library. ([Linking to Ditto](#linking-to-ditto))
  </Step>
</Steps>

### Downloading and Unpacking Ditto

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

<CodeGroup>
  ```linux x86_64 theme={null}
  curl -O https://software.ditto.live/cpp-linux-x86_64/Ditto/5.0.0/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
  ```

  ```linux aarch64 theme={null}
  curl -O https://software.ditto.live/cpp-linux-aarch64/Ditto/5.0.0/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
  ```
</CodeGroup>

### Linking to Ditto

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

<Info>
  For instructions on adding cross-platform Bluetooth Low Energy (LE) capabilities, see [Bluetooth on Linux](best-practices/how-to/bluetooth-on-linux#bluetooth-on-linux).

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

<CodeGroup>
  ```linux Linux theme={null}
  # 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++11 ./src/main.cpp -I ./sdk -lditto -ldl -lrt -pthread -L ./sdk -o dist/main;

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

## Importing and Initializing Ditto

From the source code of your app, using `#include <ditto/ditto.h>`, use the `ditto` namespace, and provide your access credentials:

```cpp C++ theme={null}
#include <ditto/ditto.h>

auto database_id = "YOUR_DATABASE_ID";
auto config = ditto::DittoConfig(
    database_id,
    ditto::DittoConnect::server("https://" + database_id + ".cloud.ditto.live")
);

auto ditto = ditto::Ditto::open(config);

ditto->auth()->set_expiration_handler([](ditto::Ditto& ditto, int64_t seconds_remaining) {
    ditto.auth()->login("YOUR_PLAYGROUND_TOKEN", ditto::Authenticator::development_provider(),
        [](const ditto::AuthenticationSuccess* success, const ditto::DittoError* error) {
            if (error) {
                std::cerr << "Auth error" << std::endl;
            }
        });
});

ditto->update_transport_config([&](ditto::TransportConfig &config) {
    config.enable_all_peer_to_peer();
});

ditto->get_sync()->start();
```
