Incorporating RSEE Into the C SDK Agent
RSEE uses the C SDK extension API to build itself as a shared library that can be loaded at runtime by a C SDK application. See the following sample code in ExampleAgent.c:
/* Dynamically load shape library and add the shape to a Generic Edge Thing */
#ifdef WIN32
#ifndef snprintf
#define snprintf _snprintf
char * fullPath = twPath_GetFullPath("./ext");
char twxLibString[MAX_PATH + 8 + 1] = { 0 };
snprintf(twxLibString, MAX_PATH + 8, "TWXLIB=%s", fullPath);

For more information on Edge Extensions see, Using Edge Extensions with the ThingWorx Edge C SDK.
Compiling the RSEE Agent Into a Single Static Binary
Static compilation is not required to build the Agent. The expected method of loading an SDK extension is to load it dynamically. Use static compilation if you do not want to load the extension at runtime
Using a static compilation, you can incorporate both RSEE and the C SDK Edge Extension into your application and remove them as dependent shared libraries or dlls.
Since static linking is done during compilation and not at runtime, you do not need to declare a TWXLIB environment variable at runtime, and call twExt_LoadExtentionLibrary() to access the contents of the library. However, you must call init_libremotesession() in your program because it is no longer called from twExt_LoadExtentionLibrary().
This can be done if you specify -DBUILD_STATIC=ON in the CMake project generation command line in the Agent example program. For example:
For -DBUILD_STATIC=ON to work, a static version of the C SDK must be built and installed on your machine. Verify that the libcsdk_static.a file or csdk_static.lib file is in the installation folder. By default, it is in /opt/thingworx/lib or C:\Program Files\tw-csdk\lib. The static library is always built by default when you compile the C SDK but may not be copied to the installation directory as part of the install for C SDK 3.1.0 or lower. When you run the cmake command, examine the output for these lines:
-- Build type: STATIC
-- Static CSDK Found at: /opt/thingworx/lib/libcsdk_static.a (tw-c-sdk.cmake)
If you see the error listed below, you must manually copy the C SDK static library to the install directory:
-- Build type: STATIC
-- Could not find an installed static C SDK. Versions of the CSDK 3.1 or less fail to install the static library.
Manually copy libcsdk_static.a or csdk_static.lib(Windows) to your install directory to resolve this CMake error.
Was this helpful?