Extract the customer SDK archive (.tar.xz on Linux or .zip on Windows). To use the archive with CMake, specify its header and library paths as shown below.
- Important
- Match the SDK's platform, compiler or MSVC toolset, architecture, C++ runtime, and application binary interface (ABI). Use the C++ standard required by that archive.
The SDK requires C++11 or later, but an archive may require a newer standard. For example, a gcc115-cpp17 archive requires C++17. If the archive name does not specify a standard, use the settings in the supplied sample build files.
Minimal application
Create an empty application directory outside the extracted SDK. Save this file as main.cpp; all the CMake examples below use it:
#include <iostream>
int main()
{
}
static Version current()
Identifies the current version of the product.
void toStr(std::string &str, BookState::Enum bookState)
Appends a string representation of a book state.
This calls the shared library and prints its version. It does not start a Handler or require a license or network connection. Run each example's commands from this application directory, with its corresponding CMakeLists.txt beside main.cpp. Replace example SDK paths before configuring.
Customer archive layout
The Linux and Windows archives use the following layouts:
| Content | Linux archive | Windows archive |
| Headers | include | include |
| Link library | lib/libonixs-cmemdh.so | lib/*.lib |
| Runtime library | lib/libonixs-cmemdh.so* | lib/*.dll |
| Samples and data | samples | samples |
| License | license | license |
| Documentation | doc/html | doc/html |
In the examples below, CMEMDH_SDK_ROOT is the absolute path to the extracted directory containing include and lib. Keep the archive's shared libraries together, including Linux versioned files and symlinks. These examples use CMake 3.18 or later and create a local imported target.
Link from the Linux archive
Save the following CMakeLists.txt beside main.cpp. This example defaults to C++17 for a cpp17 archive; set CMEMDH_CXX_STANDARD to the standard required by your archive if it differs.
cmake_minimum_required(VERSION 3.18)
project(cmemdh-example LANGUAGES CXX)
set(CMEMDH_SDK_ROOT "" CACHE PATH "Extracted SDK directory containing include and lib")
set(CMEMDH_CXX_STANDARD 17 CACHE STRING "C++ standard required by the SDK archive")
# Import only the selected archive, without searching system SDK installations.
add_library(cmemdh-sdk SHARED IMPORTED)
set_target_properties(cmemdh-sdk PROPERTIES
IMPORTED_LOCATION "${CMEMDH_SDK_ROOT}/lib/libonixs-cmemdh.so"
INTERFACE_INCLUDE_DIRECTORIES "${CMEMDH_SDK_ROOT}/include")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
add_executable(cmemdh-example main.cpp)
set_target_properties(cmemdh-example PROPERTIES
CXX_STANDARD "${CMEMDH_CXX_STANDARD}"
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
target_link_libraries(cmemdh-example PRIVATE cmemdh-sdk Threads::Threads)
Configure with the compiler matching the archive, then build and run:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-DCMEMDH_SDK_ROOT=/absolute/path/to/extracted-sdk \
-DCMEMDH_CXX_STANDARD=17 -DCMAKE_CXX_COMPILER=/path/to/matching/g++
cmake --build build
./build/cmemdh-example
CMake adds a build rpath for the imported library. When deploying the application, set an installation rpath or configure the system's runtime library search path to locate the SDK's lib directory. For a manual build, add include to the compiler's include directories, add lib to the linker's search path, and link onixs-cmemdh and pthread. For example, the supplied gcc115-cpp17 Makefiles use -std=c++17, -pthread, -I../../include, -L../../lib, and -lonixs-cmemdh, with a relative rpath to ../../lib.
Link from the Windows archive
The following CMakeLists.txt is for the v143 x64 binaries. The Release files are lib/onixs-cmemdh-v143-x64.lib and lib/onixs-cmemdh-v143-x64.dll; the Debug names have a -d suffix. For another archive, change CMEMDH_LIBRARY_NAME and select the matching generator, toolset, and architecture. Match the C++ standard to the supplied sample settings; the v143 x64 example uses C++14 and the DLL form of the MSVC runtime (/MD for Release, /MDd for Debug).
cmake_minimum_required(VERSION 3.18)
project(cmemdh-example LANGUAGES CXX)
set(CMEMDH_SDK_ROOT "" CACHE PATH "Extracted SDK directory containing include and lib")
set(CMEMDH_LIBRARY_NAME onixs-cmemdh-v143-x64)
# The .lib is used by the linker; the matching DLL is required at run time.
add_library(cmemdh-sdk SHARED IMPORTED)
set_target_properties(cmemdh-sdk PROPERTIES
IMPORTED_CONFIGURATIONS "Debug;Release"
IMPORTED_IMPLIB_RELEASE "${CMEMDH_SDK_ROOT}/lib/${CMEMDH_LIBRARY_NAME}.lib"
IMPORTED_LOCATION_RELEASE "${CMEMDH_SDK_ROOT}/lib/${CMEMDH_LIBRARY_NAME}.dll"
IMPORTED_IMPLIB_DEBUG "${CMEMDH_SDK_ROOT}/lib/${CMEMDH_LIBRARY_NAME}-d.lib"
IMPORTED_LOCATION_DEBUG "${CMEMDH_SDK_ROOT}/lib/${CMEMDH_LIBRARY_NAME}-d.dll"
MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release
MAP_IMPORTED_CONFIG_MINSIZEREL Release
INTERFACE_INCLUDE_DIRECTORIES "${CMEMDH_SDK_ROOT}/include")
add_executable(cmemdh-example main.cpp)
target_compile_features(cmemdh-example PRIVATE cxx_std_14)
set_property(TARGET cmemdh-example PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
target_link_libraries(cmemdh-example PRIVATE cmemdh-sdk)
# Copy the DLL for the selected build configuration beside the executable.
add_custom_command(TARGET cmemdh-example POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"$<TARGET_FILE:cmemdh-sdk>" "$<TARGET_FILE_DIR:cmemdh-example>"
VERBATIM)
Configure, build, and run from PowerShell:
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -T v143 `
-DCMEMDH_SDK_ROOT=C:/path/to/extracted-sdk
cmake --build build --config Release
.\build\Release\cmemdh-example.exe
cmake --build build --config Debug
.\build\Debug\cmemdh-example.exe
For a manual build, add include to the compiler's include directories and link the appropriate import library from lib. Copy the matching DLL beside the executable or add its directory to PATH. The supplied Visual Studio sample projects configure these paths and copy the DLL automatically.
Next, follow the Offline replay quickstart or Live CME channel quickstart.