C and C++ get the core library itself rather than a binding. Every other language on this site is a thin layer over the same licdongle.h ABI, so you are working with the tested primary implementation, not a translation of it.
Linking
The SDK repository is a CMake package. Fetch it by tag and link the target; the prebuilt library for your platform comes with it, and keynub_copy_runtime places it next to your executable. The library is C99 with hidden symbol visibility and explicit exports, so it drops into an existing build without polluting your namespace.
include(FetchContent)
FetchContent_Declare(keynub_licdongle
GIT_REPOSITORY https://github.com/AB-KeyNub/KeyNub-SDK.git
GIT_TAG v1.1.1)
FetchContent_MakeAvailable(keynub_licdongle)
target_link_libraries(myapp PRIVATE keynub::licdongle) # C; keynub::licdongle_cpp for the C++ wrapper
keynub_copy_runtime(myapp)Code language: CMake (cmake)
For a Visual Studio project without CMake, the same headers and libraries come as a NuGet package: referencing it adds the include path, links the library for the project’s platform (x64, x86 or ARM64) and copies it next to the executable.
For Conan, the repository carries a recipe index: add packaging/conan from a clone as a local-recipes-index remote and require keynub_licdongle/1.1.1; the recipe packages the prebuilt library for your operating system and architecture and exposes the same keynub:: targets through CMakeDeps.
xmake users take it from the xmake-repo:
add_requires("keynub_licdongle")Code language: Lua (lua)
Bazel users take it from the Bazel Central Registry; the module exposes @keynub_licdongle//:keynub_licdongle, :licdongle_cpp and :licdongle_flat:
bazel_dep(name = "keynub_licdongle", version = "1.1.1")Code language: Python (python)
Install-Package KeyNub.LicenseDongle.NativeCode language: Bash (bash)
#include <licdongle.h>
licd_ctx *ctx = NULL;
licd_device *dev = NULL;
if (licd_init(&ctx) != LICD_OK) return 1;
if (licd_open(ctx, NULL, &dev) != LICD_OK) return 1; /* first dongle */
licd_genuine_result g;
if (licd_verify_genuine(dev, &g) != LICD_OK) return 1;
licd_session_open(dev);
unsigned char buf[256];
uint32_t len = 0, total = 0;
licd_record_read(dev, "license", 0, buf, sizeof buf, &len, &total, NULL, NULL);
licd_session_close(dev);
licd_close(dev);
licd_free(ctx);Code language: Arduino (arduino)
Two-Call Buffer Convention
Anything that returns variable-length data follows one rule: call it with a capacity of zero to learn the size it needs, then call it again with a buffer. A zero-length record is a success with a length of zero, not an error.
C++
The SDK ships an RAII wrapper: construction opens, destruction closes, errors become exceptions if you want them to. Nothing in it is required — it is a header over the same C API, so mixing the two is fine.
Where to Put the Check
Native code is the hardest target on this site, but a single if (genuine) is still a single conditional jump, and the people who do this for a living find those quickly. Use licd_app_decrypt on data your program needs, so that patching the check produces a program with nothing to compute rather than a working unlicensed copy.
Shipping the Native Library with a C or C++ Application
The repository is a CMake package: find_package(keynub_licdongle) gives the keynub::licdongle target (and keynub::licdongle_cpp for the header-only C++ wrapper), and keynub_copy_runtime(myapp) puts the shared library next to the executable at build time. Visual Studio projects take the KeyNub.LicenseDongle.Native NuGet package, which brings headers, import libraries and DLLs for x64, x86 and ARM64 with a .targets file that sets the include path, links and copies the DLL. xmake users take keynub_licdongle from the xmake repository.
Each platform folder also holds a static library (keynub_licdongle_static.lib or .a) for a self-contained executable. The header licdongle.h is C99 with a stable ABI across 1.x, so a newer library is a drop-in replacement. On Linux, install the udev rule from NATIVES.md once, so that ordinary users may open the device.
Questions C or C++ Developers Ask
Which Compilers and Standards Does the C API Need?
Any C99 compiler for the C API; the C++ wrapper is header-only and needs C++11. The Windows libraries are MSVC builds with import libraries for x64, x86 and ARM64; Linux and macOS take GCC or Clang.
Can I Link the Dongle Library Statically?
Yes. A static library sits beside the shared one in every platform folder, with the system libraries it needs listed in NATIVES.md (IOKit and CoreFoundation on macOS, udev and pthread on Linux).
Does a C or C++ Application Need Administrator Rights to Talk to the Dongle?
No, and no driver either: the dongle is a USB HID device that the operating systems handle with their built-in class drivers. On Linux, install the shipped udev rule once so that ordinary users may open it; without the rule the SDK reports access denied and names the cause in its error detail.
Does a C or C++ License Check Need an Internet Connection?
No. Verification is a local exchange between your program and the dongle over USB: the SDK checks the dongle’s certificate chain to KeyNub’s root and runs a live challenge-response. There is no activation server and no account, so the check works on air-gapped machines.
Does It Run on ARM: Windows on ARM, Apple Silicon, aarch64 Linux?
Yes. The SDK ships native libraries for Windows x64, x86 and ARM64, Linux x86_64 and aarch64, and universal macOS binaries for Intel and Apple silicon.
Who Can Read the License Records on a Dongle?
Anyone holding the dongle: a program opens a session and reads records, and can decrypt data sealed for that dongle. Writing records, erasing them and incrementing counters need your write key. What the dongle guarantees is that none of it is available without the dongle present.
Code
Runnable sample: c/verify_and_read, cpp/verify_and_read, flat/verify_and_read.c. Binding source: bindings/cpp. Both are Apache-2.0, in the public SDK repository; the prebuilt native libraries are in the repository’s natives/ folder, one per platform.
All supported languages · All industries · Buy a KeyNub · Ask us something