---
title: C / C++ Advanced Build Configuration
description: >-
  Configure the Datadog C++ SDK build for non-CMake projects, customize CMake
  options, and understand platform-specific linker requirements.
breadcrumbs: >-
  Docs > RUM & Session Replay > Application Monitoring > C / C++ Monitoring > C
  / C++ Advanced Build Configuration
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# C / C++ Advanced Build Configuration

## Overview{% #overview %}

This page covers build configuration topics beyond the standard CMake setup described in [C / C++ Monitoring Setup](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/cpp/setup.md). It includes instructions for integrating the SDK into projects that don't use CMake.

## CMake targets and datadog_enable(){% #cmake-targets-and-datadog_enable %}

To add the SDK as a dependency in your CMake project, pass your executable target to `datadog_enable()`:

```cmake
add_executable(my-app main.cpp)
datadog_enable(my-app)
```

This function adds the SDK as a dependency while also configuring additional build steps as required by your build configuration.

If you prefer to configure CMake dependencies directly, you can use the `Datadog::sdk` target:

```cmake
target_link_libraries(my-app PRIVATE Datadog::sdk)
```

See [`DatadogConvenience.cmake`](https://github.com/DataDog/dd-sdk-cpp/blob/main/cmake/DatadogConvenience.cmake) for a full definition of `datadog_enable()`.

## CMake installation rules and datadog_install(){% #cmake-installation-rules-and-datadog_install %}

Depending on build configuration, you may need to package additional files with installable builds of your application.

If you're using `install()` to define installation rules for your CMake project, call `datadog_install()`:

```cmake
install(TARGETS my-app RUNTIME DESTINATION bin LIBRARY DESTINATION lib)
datadog_install(my-app
   RUNTIME_DESTINATION bin  # Optional, defaults to CMAKE_INSTALL_BINDIR if set
   LIBRARY_DESTINATION lib  # Optional, defaults to CMAKE_INSTALL_LIBDIR if set
                            # (Not used for Windows or static-library builds)
)
```

This function deploys all required runtime artifacts alongside your application binary when using `cmake --install` or building generated "install" targets.

See [`DatadogConvenience.cmake`](https://github.com/DataDog/dd-sdk-cpp/blob/main/cmake/DatadogConvenience.cmake) for a full definition of `datadog_install()`.

## Customizing the SDK build{% #customizing-the-sdk-build %}

You can customize the SDK build with CMake options when building from source using `FetchContent` or when creating precompiled binaries for a non-CMake build:

- In a `CMakeList.txt` or `.cmake` file: `set(DD_CRASH_MODE inprocess)`
- When configuring the project with `cmake`: `cmake -DDD_CRASH_MODE=inprocess ...`
- In the CMake GUI

These are several important options to consider when building the SDK from source.

| Option                       | Description                                                                                                                                                                                                                          |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `CMAKE_BUILD_TYPE`           | This is a standard CMake option, typically `RelWithDebInfo` or `Release` for production builds. If you incorporate the SDK as a dependency with `FetchContent`, you are responsible for setting this option in your project's build. |
| `DD_BUILD_SHARED`            | `OFF`: The SDK is built as a static library.`ON`: The SDK is built as a shared/dynamic library.Defaults to the value of `BUILD_SHARED_LIBS`, which is `OFF` by default.                                                              |
| `DD_CRASH_MODE`              | `inprocess` (default): The SDK uses an in-process handler to detect crashes.`noop`: The SDK does not detect crashes.                                                                                                                 |
| `DD_HTTP_USE_SYSTEM_LIBCURL` | `OFF`: libcurl is built from source as a static library and linked into the SDK.`ON`: The SDK uses system-installed shared libraries for libcurl.Defaults to `OFF` for Windows builds, `ON` for Linux and macOS.                     |

For a full list of configuration options, see the [SDK source](https://github.com/DataDog/dd-sdk-cpp).

## Integrating the SDK into a non-CMake build{% #integrating-the-sdk-into-a-non-cmake-build %}

If your application is not built with CMake, you can link against `libddsdkcpp.a` (or `ddsdkcpp.lib` on Windows) using your project's build system. You have two options for obtaining a ready-to-link build of the SDK:

1. **Use precompiled binaries:** download an officially-published Datadog release.
1. **Build from source:** clone the SDK and build it yourself.

### Using precompiled binaries{% #using-precompiled-binaries %}

From the SDK's [GitHub Releases](https://github.com/DataDog/dd-sdk-cpp/releases) page, find your chosen release, then download the archive for your platform. Extract its contents to a directory within your project: the example below uses `external/datadog-sdk/`.

### Building from source{% #building-from-source %}

Alternatively, you can build your own SDK binaries. Clone the SDK, configure it with your desired CMake options, run a build, and then use `cmake --install` to deploy it to a directory within your project. For example:

{% tab title="POSIX" %}

```
git clone https://github.com/DataDog/dd-sdk-cpp.git
cd dd-sdk-cpp
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -S . -B build
cmake --build build
cmake --install build --prefix "$YOUR_PROJECT/external/datadog-sdk/"
```

{% /tab %}

{% tab title="Windows" %}

```
git clone https://github.com/DataDog/dd-sdk-cpp.git
cd dd-sdk-cpp
cmake -G"Visual Studio 17 2022" -S . -B build
cmake --build build --config RelWithDebInfo
cmake --install build --config RelWithDebInfo --prefix "%YOUR_PROJECT%\external\datadog-sdk"
```

{% /tab %}

This populates `external/datadog-sdk/`, placing all required files in `include/`, `lib/`, etc.

### Configuring compiler and linker dependencies{% #configuring-compiler-and-linker-dependencies %}

After preparing a redistributable build of the SDK, make the following changes to your project's build configuration:

- **Include directories:** Add `external/datadog-sdk/include/`
- **Library directories:** Add `external/datadog-sdk/lib/`
- **Libraries to link:** Add `-lddsdkcpp` on POSIX; `ddsdkcpp.lib` on Windows

You may also need to add a few other libraries, depending on your platform:

{% tab title="Linux" %}
On Linux, linking against the SDK requires:

- `-luuid`
- `-lcurl` (unless the SDK is built with `DD_HTTP_USE_SYSTEM_LIBCURL=OFF`)

{% /tab %}

{% tab title="macOS" %}
On macOS, linking against the SDK requires:

- `-framework CoreFoundation`
- `-lcurl` (unless the SDK is built with `DD_HTTP_USE_SYSTEM_LIBCURL=OFF`)

{% /tab %}

{% tab title="Windows" %}
On Windows, linking against the SDK requires:

- `ole32.lib`
- `wbemuuid.lib`

MSVC should include these libraries automatically thanks to `#pragma` directives.
{% /tab %}

### Deploying additional files{% #deploying-additional-files %}

If you've built the SDK as a shared library, bundle the shared library with your application:

- **Linux:** `libddsdkcpp.so`
- **macOS:** `libddsdkcpp.dylib`
- **Windows:** `ddsdkcpp.dll`

On macOS and Linux, your executable's runtime search path must also include the location of this file.

## Further Reading{% #further-reading %}

- [C / C++ Monitoring Setup](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/cpp/setup.md)
- [Source code for dd-sdk-cpp](https://github.com/DataDog/dd-sdk-cpp)
- [Explore Datadog RUM](https://docs.datadoghq.com/real_user_monitoring.md)
