> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# C/C++ (client-side) SDK 1.x to 2.0 migration guide

> This topic explains the API changes made in the C/C++ client-side SDK 2 release and how to migrate to that version.

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

## Overview

This topic explains how to adapt code that currently uses a 1.x version of the [C/C++ client-side SDK](/sdk/client-side/c-c--) to use version 2.0.

To learn more about updating to the latest 2.x version, visit the [SDK's GitHub repository](https://github.com/launchdarkly/c-client-sdk/releases).

## Build system changes

The C/C++ client-side SDK previously used `make` on POSIX, and `nmake` on Windows. We have transitioned to the cross platform `cmake` build system, similar to the C/C++ server-side SDK.

We recommend that you use the prebuilt releases if they exist for your platform available on the [GitHub releases page](https://github.com/launchdarkly/c-client-sdk/releases).

You can produce a simple build on Linux or OSX by using the following command:

<CodeGroup>
  ```bash title="1.x syntax" theme={null}
      make
  ```

  ```bash title="2.0 syntax" theme={null}
      mkdir build && cd build
      cmake ..
      make
  ```
</CodeGroup>

For more advanced `cmake` usage, or if you use another platform, read this [cmake guide](http://preshing.com/20170511/how-to-build-a-cmake-based-project). The SDK is exported as the `ldclientapi` target.

You should not consider the repository organization of source files stable. If you want to build your own artifacts and use them outside of a cmake project, `cmake install` to your directory of choice which will copy the required headers and binary.

## Header and typedef changes

In version 1.x, the SDK required you to import `uthash.h`, and `ldapi.h`. Now, similarly to the C/C++ server-side SDK, you should import the SDK with the following command:

<CodeGroup>
  ```c title="1.x syntax" theme={null}
      #include "ldapi.h"
      #include "uthash.h"
  ```

  ```c title="2.0 syntax" theme={null}
      #include <launchdarkly/api.h>
  ```
</CodeGroup>

The types `LDClient`, `LDConfig`, and `LDUser` are no longer typedefs. They require the `struct` prefix:

<CodeGroup>
  ```c title="1.x syntax" theme={null}
      LDClient *client;
      LDUser *user;
      LDConfig *config;
  ```

  ```c title="2.0 syntax" theme={null}
      struct LDClient *client;
      struct LDUser *user;
      struct LDConfig *config;
  ```
</CodeGroup>

In version 1.x of the SDK, when you compiled it with C++, `LDClient` was defined as a class instead of a C struct. We removed this system in version 2.0, and now `LDClient` is always a C style struct.

If you prefer a C++ interface, we added a dedicated `LDClientCPP` class that shares substantially the same API as you would have used with the 1.x C++ `LDClient`.

The entry point for the C++ interface is `launchdarkly/api.hpp` and you must link with the `ldclientapicpp` target instead of `ldclientapi`. As is standard, you can use the standard C interface in a C++ project.

## Logging changes

We have removed the logging interface from the 1.x versions, which was specific to the client-side SDK. C/C++ client

* and server-side SDKs now use the same interface.

For example, to configure the SDK to use the default included logger:

<CodeGroup>
  ```c title="1.x syntax" theme={null}
      LDSetLogFunction(LD_LOG_INFO, yourLogger);
  ```

  ```c title="2.0 syntax" theme={null}
      LDConfigureGlobalLogger(LD_LOG_INFO, LDBasicLogger);
  ```
</CodeGroup>

## JSON representation changes

The C/C++ client-side SDK 1.x used a JSON representation utilizing the `uthash.h` library. We removed this old representation completely and now use the C/C++ server-side SDK JSON interface instead. Every function relating to `LDNode` has been modified to utilize `struct LDJSON` instead. This includes `LDJSONVariation` and custom user attributes.

For example, to create a basic array, use:

<CodeGroup>
  ```c title="1.x syntax" theme={null}
      LDNode *names;

      names = LDNodeCreateArray();

      LDNodeAppendString(&names, "alice");
      LDNodeAppendString(&names, "bob");

      LDNodeFree(names);
  ```

  ```c title="2.0 syntax" theme={null}
      struct LDJSON *names, *tmp;

      names = LDNewArray();

      tmp = LDNewText("alice");
      LDArrayPush(names, tmp);

      tmp = LDNewText("bob");
      LDArrayPush(names, tmp);

      LDJSONFree(names);
  ```
</CodeGroup>

For complete documentation on manipulating JSON, read our [API docs on GitHub](https://launchdarkly.github.io/c-client-sdk/json_8h.html).
