This repository contains LaunchDarkly SDK packages which are written in C++. This includes shared libraries, used by SDKs and other tools, as well as SDKs.
Readme | issues | tests | docs (C++) | docs (C) | latest release |
---|---|---|---|---|---|
libs/client-sdk | C++ Client SDK | On Github | |||
libs/server-sdk | C++ Server SDK | On Github | |||
libs/server-sdk-redis-source | C++ Server SDK - Redis Source | On Github |
Shared packages | issues | tests |
---|---|---|
libs/common | Common | |
libs/internal | Internal | |
libs/server-sent-events | Common Server-Sent-Events |
Directory | Description |
---|---|
.github | Contains CI and release process workflows and actions. |
examples | Contains examples (hello-world style). |
contract-tests | Contains contract test service. |
cmake | Contains cmake files for importing and configuring external libraries. |
libs | Contains library implementations. This includes libraries shared within the project as well as SDK libraries like the client-sdk. |
scripts | Contains scripts used in the release process. |
vendor | Contains third party source which is directly integrated into the project. Generally third party source is included through CMake using FetchContent, but some libraries require modification specific to this repository. |
[!NOTE]
Boost 1.83 is not supported due to an incompatibility in Boost.JSON. This issue appears to be resolved in versions prior and subsequent to 1.83.
Additional dependencies are fetched via CMake. For details see the cmake
folder.
GoogleTest is used for testing.
For information on integrating an SDK package please refer to the SDK specific README.
Various CMake options are available to customize the client/server SDK builds.
Option | Description | Default | Requires |
---|---|---|---|
BUILD_TESTING |
Coarse-grained switch; turn off to disable all testing and only build the SDK targets. | On | N/A |
LD_BUILD_UNIT_TESTS |
Whether C++ unit tests are built. | On | BUILD_TESTING; NOT LD_BUILD_SHARED_LIBS |
LD_TESTING_SANITIZERS |
Whether sanitizers should be enabled. | On | LD_BUILD_UNIT_TESTS |
LD_BUILD_CONTRACT_TESTS |
Whether the contract test service (used in CI) is built. | Off | BUILD_TESTING |
LD_BUILD_EXAMPLES |
Whether example apps (hello world) are built. | On | N/A |
LD_BUILD_SHARED_LIBS |
Whether the SDKs are built as static or shared libraries. | Off (static lib) | N/A |
LD_BUILD_EXPORT_ALL_SYMBOLS |
Whether to export all symbols in shared libraries. By default, only C API symbols are exported because C++ does not have an ABI. Only use this feature if you understand the risk and requirements. A mismatch in ABI could cause crashes or other unexpected behaviors. | Off (hidden) | LD_BUILD_SHARED_LIBS |
LD_DYNAMIC_LINK_BOOST |
If building SDK as shared lib, whether to dynamically link Boost or not. Ensure that the shared boost libraries are present on the target system. | On (link boost dynamically when producing shared libs) | LD_BUILD_SHARED_LIBS |
LD_DYNAMIC_LINK_OPENSSL |
Whether OpenSSL is dynamically linked or not. | Off (static link) | N/A |
LD_BUILD_REDIS_SUPPORT |
Whether the server-side Redis Source is built or not. | Off | N/A |
[!WARNING]
When building shared libraries C++ symbols are not exported, only the C API will be exported. This is because C++ does not have a stable ABI. For this reason, the SDK's unit tests are not built in shared library mode.
To configure the SDK's CMake project:
# Use 'make' as the build system.
cmake -B build -S . -G"Unix Makefiles"
To pass in config options defined in the table above, add them using -D
:
# Use 'make' as the build system, build shared libs, and disable testing.
cmake -B build -S . -G"Unix Makefiles" \
-DLD_BUILD_SHARED_LIBS=On \
-DBUILD_TESTING=Off ..
The example uses make
, but you might instead use Ninja,
MSVC, etc.
add_subdirectory
The SDK can be incorporated into an existing application using CMake via add_subdirectory.
.
# Set SDK build options, for example:
set(LD_BUILD_SHARED_LIBS On)
add_subdirectory(path-to-cpp-sdks-repo)
target_link_libraries(your-app PRIVATE launchdarkly::client)
# ... or launchdarkly::server
find_package
[!WARNING]
Preliminary support forfind_package
is available. The package configuration is subject to change, do not expect it to be stable as long as this notice is present.
If you've installed the SDK on the build system via cmake --install
, you can consume it from
the target application like so:
find_package(launchdarkly REQUIRED)
target_link_libraries(your-app PRIVATE launchdarkly::launchdarkly-cpp-client)
# ... or launchdarkly::launchdarkly-cpp-server
LaunchDarkly is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!
We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly.
We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.