This section describes how to set up and install the C/C++ SDK and how to deploy a feature flag.
Step 1 - Setting up the C/C++ Client SDK
To setup the C/C++ SDK, follow these steps:
-
Create a CloudBees Feature Management account. See Signup Page to create an account.
-
Get your environment key. Copy your environment key from App settings > Environments > Key.
Step 2 - Installing the C/C++ Client SDK
-
For instructions on installing the C/C++ package in your application, select your operating system:
Linux or macOS
-
Install the prerequisites:
LinuxmacOS$ apt-get install cmake gcc git
$ brew install cmake gcc git
-
Clone the Rox C SDK Repository at the root of the workspace directory.
$ git clone https://github.com/rollout/rox-c.git
-
Run the installation script. This will install the SDK to the subdirectory specified in the command. If the optional
-p
parameter is omitted, the installation will require superuser privileges, and the SDK will be installed at/usr/local/rollout-sdk
.$ cd rox-c && ./install.sh -d /path/to/install/dir
Windows
-
To make sure the OpenSSL and Curl libraries can be built on Windows, install the following and ensure the executables are added to
PATH
:-
Strawberry Perl (http://strawberryperl.com/)
-
NASM (https://www.nasm.us/)
-
CMake 3.9 or higher
-
Visual Studio with C Compiler tools installed
-
Git
-
-
Open Cross Tools Command Prompot for VS.
-
Clone the repository:
> git clone https://github.com/rollout/
-
Navigate to the repository root folder.
-
Install the SDK to the desired
%INSTALLATION_PATH%
. If omitted, the SDK will require Administrator permissions, to install atC:\Program Files\rollout-sdk
.> install %INSTALLATION_PATH%
-
(OPTIONAL) add
%INSTALLATION_PATH%\bin
to systemPATH
variable.
Add the following lines of code to your application
#include <rox/client.h> #include <stdio.h> #define DEFAULT_API_KEY <CBFF_ENV_KEY> #define DEFAULT_DEV_MODE_KEY "null" int main(int argc, char **argv) { RoxStringBase *demo_flag = rox_add_flag_with_freeze("demo.demoFlag", false, RoxFreezeUntilLaunch); RoxOptions *options = rox_options_create(); rox_options_set_dev_mode_key(options, DEFAULT_DEV_MODE_KEY); rox_setup(DEFAULT_API_KEY, options); char c = 'Y'; while (c != 'n' && c != 'N') { printf("Demo flag is %s\n", rox_flag_is_enabled(demo_flag) ? "ON" : "OFF"); printf("Continue? (Y/n):"); c = fgetc(stdin); if ((c == '\n' || c == EOF)) { // Enter key pressed c = 'Y'; } else { getchar(); // read dummy character to clear input buffer, which inserts after character input } printf("\n"); } rox_shutdown(); return 0; }
#include <roxx/client.h> #include <cstdio> #define DEFAULT_API_KEY <CBFF_ENV_KEY> #define DEFAULT_DEV_MODE_KEY "null" int main(int argc, char **argv) { Rox::Client::Flag *demoFlag = Rox::Client::Flag::Create("demo.demoFlag", false, RoxFreezeUntilLaunch); Rox::Options *options = Rox::OptionsBuilder() .SetDevModeKey(DEFAULT_DEV_MODE_KEY) .Build(); Rox::Setup(DEFAULT_API_KEY, options); char c = 'Y'; while (c != 'n' && c != 'N') { printf("Demo flag is %s\n", demoFlag->IsEnabled() ? "ON" : "OFF"); printf("Continue? (Y/n):"); c = fgetc(stdin); if ((c == '\n' || c == EOF)) { // Enter key pressed c = 'Y'; } else { getchar(); // read dummy character to clear input buffer, which inserts after character input } printf("\n"); } Rox::Shutdown(); return 0; }
Container class registration and environment key setup
|