You can integrate prebuilt LiteRT C++ libraries (libLiteRt.so,
libLiteRt.dylib, or libLiteRt.dll) and the LiteRT C++ SDK (litert_cc_sdk)
into your CMake application using dynamic linking—without building the LiteRT
source tree with Bazel.
LiteRT C++ SDK headers and thin C++ wrappers compile into a lightweight static
target (litert_cc_api) that delegates all runtime calls to the prebuilt
libLiteRt shared library.
Download prebuilt LiteRT archives or individual binaries
You can either download the all-in-one prebuilt archive
(litert_prebuilts.zip
for the latest stable release, or
2.4.0/litert_prebuilts.zip
for a pinned version), or download the C++ SDK and platform libraries
individually from the following tables.
LiteRT 2.4.0 is the first numbered release that includes the windows_arm64 and
aarch64-oe-linux-gcc11.2 platform directories, Qualcomm NPU libraries for
linux_arm64 and windows_arm64, the Intel OpenVINO dispatch library for
linux_x86_64, Intel OpenVINO NPU libraries for windows_x86_64, and
apply_plugin_main.exe for Windows. Earlier numbered releases don't include
these binaries.
LiteRT runtime shared libraries
| Platform | Version | LiteRT runtime library |
|---|---|---|
| android_arm32 | 2.4.0 | libLiteRt.so |
| android_arm64 | 2.4.0 | libLiteRt.so |
| android_x86_64 | 2.4.0 | libLiteRt.so |
| linux_x86_64 | 2.4.0 | libLiteRt.so |
| linux_arm64 | 2.4.0 | libLiteRt.so |
| aarch64-oe-linux-gcc11.2 | 2.4.0 | libLiteRt.so |
| ios_arm64 | 2.4.0 | libLiteRt.dylib |
| ios_sim_arm64 | 2.4.0 | libLiteRt.dylib |
| macos_arm64 | 2.4.0 | libLiteRt.dylib |
| windows_x86_64 | 2.4.0 | libLiteRt.dll |
| windows_arm64 | 2.4.0 | libLiteRt.dll |
Download prebuilt GPU accelerators
If you need GPU acceleration, download the prebuilt GPU accelerator for your target platform from the following table, or build the Android GPU accelerator from source following the GPU Accelerator Build Instructions.
| Platform | Version | GPU accelerator | Backend |
|---|---|---|---|
| android_arm32 | 2.4.0 | libLiteRtClGlAccelerator.so | OpenCL + OpenGL |
| android_arm64 | 2.4.0 | libLiteRtClGlAccelerator.so | OpenCL + OpenGL |
| android_x86_64 | 2.4.0 | libLiteRtClGlAccelerator.so | OpenCL + OpenGL |
| android_arm64 | 2.4.0 | libLiteRtWebGpuAccelerator.so | WebGPU (Vulkan) |
| android_x86_64 | 2.4.0 | libLiteRtWebGpuAccelerator.so | WebGPU (Vulkan) |
| linux_x86_64 | 2.4.0 | libLiteRtWebGpuAccelerator.so | WebGPU (Vulkan) |
| linux_arm64 | 2.4.0 | libLiteRtWebGpuAccelerator.so | WebGPU (Vulkan) |
| ios_arm64 | 2.4.0 | libLiteRtMetalAccelerator.dylib | Metal |
| ios_sim_arm64 | 2.4.0 | libLiteRtMetalAccelerator.dylib | Metal |
| macos_arm64 | 2.4.0 | libLiteRtMetalAccelerator.dylib | Metal |
| windows_x86_64 | 2.4.0 | libLiteRtWebGpuAccelerator.dll | WebGPU (Direct3D 12) |
| windows_arm64 | 2.4.0 | libLiteRtWebGpuAccelerator.dll | WebGPU (Direct3D 12) |
Download prebuilt NPU libraries and AOT tools
To run models on NPUs (either with offline AOT compilation or on-device JIT
compilation), download the corresponding dispatch library, compiler plugin, and
host AOT compiler tool (apply_plugin_main):
| Platform | Version | Component | Prebuilt binary |
|---|---|---|---|
| linux_x86_64 | 2.4.0 | Offline AOT CLI | apply_plugin_main |
| linux_x86_64 | 2.4.0 | Compiler plugins (AOT) | libLiteRtCompilerPlugin_Qualcomm.so, MediaTek, Google Tensor, Intel OpenVINO |
| linux_x86_64 | 2.4.0 | Intel OpenVINO NPU dispatch | libLiteRtDispatch_IntelOpenvino.so |
| android_arm64 | 2.4.0 | NPU dispatch | libLiteRtDispatch_Qualcomm.so, MediaTek, Google Tensor |
| android_arm64 | 2.4.0 | Compiler plugins (JIT) | libLiteRtCompilerPlugin_Qualcomm.so, MediaTek, Google Tensor |
| linux_arm64 | 2.4.0 | Qualcomm NPU dispatch + compiler plugin (IoT) | libLiteRtDispatch_Qualcomm.so, libLiteRtCompilerPlugin_Qualcomm.so |
| aarch64-oe-linux-gcc11.2 | 2.4.0 | Qualcomm NPU dispatch + compiler plugin (IoT) | libLiteRtDispatch_Qualcomm.so, libLiteRtCompilerPlugin_Qualcomm.so |
| windows_arm64 | 2.4.0 | Offline AOT CLI | apply_plugin_main.exe |
| windows_arm64 | 2.4.0 | Qualcomm NPU dispatch + compiler plugin | LiteRtDispatch_Qualcomm.dll, LiteRtCompilerPlugin_Qualcomm.dll |
| windows_x86_64 | 2.4.0 | Offline AOT CLI | apply_plugin_main.exe |
| windows_x86_64 | 2.4.0 | Intel OpenVINO NPU dispatch + compiler plugin (MSVC ABI) | LiteRtDispatch_IntelOpenvino.dll, LiteRtCompilerPlugin_IntelOpenvino.dll |
Prepare prebuilt LiteRT C++ SDK
Choose a folder to host the LiteRT C++ SDK, referred to as
<litert_cc_sdk_location>.
Download the C++ SDK (
litert_cc_sdk):Download
litert_cc_sdk.zipfrom GitHub Releases or frombinaries/2.4.0/litert_cc_sdk.zip, or extractlitert_cc_sdk/fromlitert_prebuilts.zip:wget https://storage.googleapis.com/litert/binaries/2.4.0/litert_cc_sdk.zip unzip litert_cc_sdk.zip -d <litert_cc_sdk_location>Place the target platform's LiteRT runtime library into
litert_cc_sdk/:litert_cc_sdk/CMakeLists.txtexpects the runtime library (libLiteRt.so,libLiteRt.dylib, orlibLiteRt.dll) at the root of thelitert_cc_sdk/directory:cp <path_to_prebuilt_lib>/libLiteRt.so <litert_cc_sdk_location>/litert_cc_sdk/On Windows, copy
libLiteRt.dllfrom thewindows_arm64orwindows_x86_64directory instead:copy <prebuilt_location>\windows_arm64\libLiteRt.dll <litert_cc_sdk_location>\litert_cc_sdk\The Windows prebuilt package doesn't include an import library (
libLiteRt.lib). CMake generates one fromlibLiteRt.dllduring configuration usingdumpbinandlib.(Optional) Verify standalone SDK build and sample tools:
On Linux and macOS, the LiteRT C++ SDK requires
clang(C++20) and CMake3.22+(with network access on the first configure so CMakeFetchContentcan downloadabseil-cpp,flatbuffers, andopencl_headers):cd <litert_cc_sdk_location> cmake -S litert_cc_sdk -B litert_cc_sdk_build \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ cmake --build litert_cc_sdk_build -jOn Windows, use Visual Studio 2022 or later with the MSVC toolchain for your target architecture, CMake
3.23+, andninja. From the matching Visual Studio developer shell (for example, ARM64 Native Tools Command Prompt), use thewindows-arm64preset:cd <litert_cc_sdk_location> cmake -S litert_cc_sdk --preset windows-arm64 cmake --build litert_cc_sdk\cmake_build_windows_arm64 -jFor x64, run
cmake -S litert_cc_sdk --preset windows-x64from an x64 developer shell, and buildlitert_cc_sdk\cmake_build_windows_x64.
Integrate prebuilt LiteRT C++ SDK into your CMake project
Configure your application's
CMakeLists.txt:To build your application against any target platform without modifying the unpacked
litert_cc_sdk/folder in place, stagelitert_cc_sdk/and the target platform's LiteRT runtime library into your CMake build directory and add it withEXCLUDE_FROM_ALL:cmake_minimum_required(VERSION 3.22) project(my_litert_app LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(LITERT_CC_SDK_DIR "" CACHE PATH "Path to unpacked litert_cc_sdk directory") set(LITERT_PREBUILT_DIR "" CACHE PATH "Path to platform prebuilt directory containing libLiteRt") if(WIN32) set(_LITERT_C_API_LIB_NAME "libLiteRt.dll") elseif(APPLE) set(_LITERT_C_API_LIB_NAME "libLiteRt.dylib") else() set(_LITERT_C_API_LIB_NAME "libLiteRt.so") endif() # Stage litert_cc_sdk/ and the target platform's libLiteRt together. # On Windows, litert_cc_sdk/CMakeLists.txt generates libLiteRt.lib (IMPORTED_IMPLIB) # from libLiteRt.dll via dumpbin /exports and lib /def if libLiteRt.lib is not present. set(_LITERT_SDK_STAGED "${CMAKE_BINARY_DIR}/litert_cc_sdk_staged") file(MAKE_DIRECTORY "${_LITERT_SDK_STAGED}") file(COPY "${LITERT_CC_SDK_DIR}/" DESTINATION "${_LITERT_SDK_STAGED}") file(COPY "${LITERT_PREBUILT_DIR}/${_LITERT_C_API_LIB_NAME}" DESTINATION "${_LITERT_SDK_STAGED}") add_subdirectory( "${_LITERT_SDK_STAGED}" "${CMAKE_BINARY_DIR}/litert_cc_sdk_build" EXCLUDE_FROM_ALL ) add_executable(my_litert_app main.cc) # litert_cc_api declares the SDK header tree, generated includes, Abseil, and # FlatBuffers as PUBLIC dependencies, so linking litert_cc_api propagates # those include directories automatically. target_link_libraries(my_litert_app PRIVATE litert_cc_api ) if(WIN32) add_custom_command(TARGET my_litert_app POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_LITERT_SDK_STAGED}/libLiteRt.dll" "$<TARGET_FILE_DIR:my_litert_app>/libLiteRt.dll" ) elseif(ANDROID) target_link_libraries(my_litert_app PRIVATE "${_LITERT_SDK_STAGED}/${_LITERT_C_API_LIB_NAME}" log android dl ) elseif(UNIX) target_link_libraries(my_litert_app PRIVATE "${_LITERT_SDK_STAGED}/${_LITERT_C_API_LIB_NAME}" pthread dl ) if(APPLE) set(_LITERT_RPATH "@loader_path") else() set(_LITERT_RPATH "$ORIGIN") endif() set_target_properties(my_litert_app PROPERTIES BUILD_RPATH "${_LITERT_RPATH}" INSTALL_RPATH "${_LITERT_RPATH}" ) endif()Configure and build for your target platform:
Linux (
x86_64or nativearm64):cmake -S . -B build/linux -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \ -DLITERT_CC_SDK_DIR=<litert_cc_sdk_location>/litert_cc_sdk \ -DLITERT_PREBUILT_DIR=<prebuilt_location>/linux_x86_64 cmake --build build/linux -jFor native
arm64, setLITERT_PREBUILT_DIRto thelinux_arm64directory.Windows (
x86_64orarm64): From a Visual Studio developer shell withninja:cmake -S . -B build\windows_x64 -G Ninja -DCMAKE_BUILD_TYPE=Release ^ -DLITERT_CC_SDK_DIR=<litert_cc_sdk_location>\litert_cc_sdk ^ -DLITERT_PREBUILT_DIR=<prebuilt_location>\windows_x86_64 cmake --build build\windows_x64 -jFor
arm64, run the same commands from an ARM64 developer shell, usingbuild\windows_arm64as the build directory and settingLITERT_PREBUILT_DIRto thewindows_arm64directory.Android (
arm64-v8awith Android NDK):cmake -S . -B build/android_arm64 -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \ -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=26 \ -DLITERT_CC_SDK_DIR=<litert_cc_sdk_location>/litert_cc_sdk \ -DLITERT_PREBUILT_DIR=<prebuilt_location>/android_arm64 cmake --build build/android_arm64 -jANDROID_PLATFORM=26enablesAHardwareBuffersupport; use a higher API level if required by your target NPU backend.
Runtime library placement and hardware acceleration
Because litert_cc_api links dynamically against the LiteRT runtime library
(libLiteRt.so, libLiteRt.dylib, or libLiteRt.dll) and loads hardware
accelerators and NPU plugins at runtime, place the shared libraries on device
according to the following rules:
| Component | How LiteRT locates the library | Placement rule |
|---|---|---|
libLiteRt.so |
System dynamic linker (RUNPATH=$ORIGIN, LD_LIBRARY_PATH, or APK jniLibs) |
Place in the same directory as your executable, on LD_LIBRARY_PATH, or in jniLibs/arm64-v8a/. |
GPU accelerator (libLiteRtClGlAccelerator.so, libLiteRtWebGpuAccelerator.so) |
Loaded dynamically using dlopen from LD_LIBRARY_PATH or APK jniLibs. On Android, LiteRT probes libLiteRtClGlAccelerator.so (OpenCL/GL) before libLiteRtWebGpuAccelerator.so (WebGPU). |
Place the GPU accelerator .so on LD_LIBRARY_PATH or in jniLibs. On Android, if you want to select between OpenCL and WebGPU, keep them in separate directories and expose only the selected directory on LD_LIBRARY_PATH. |
NPU Dispatch (libLiteRtDispatch_*.so) |
Searched only in the directory passed to EnvironmentOptions::Tag::kDispatchLibraryDir (LD_LIBRARY_PATH is not searched). |
Configure kDispatchLibraryDir when creating litert::Environment. Put only one vendor's dispatch library in this directory and its subdirectories: LiteRT searches it recursively and loads the first match. |
NPU Compiler Plugin (libLiteRtCompilerPlugin_*.so) |
Searched in EnvironmentOptions::Tag::kCompilerPluginLibraryDir (needed for on-device JIT compilation). |
Configure kCompilerPluginLibraryDir when running on-device JIT compilation. |
Qualcomm QNN Host & Hexagon DSP Skel (libQnnHtp.so, libQnnSystem.so, libQnnHtpV*Stub.so, libQnnHtpV*Skel.so) |
QNN libraries are searched in QualcommOptions::GetQnnLibDir(), then in the directory of the loaded Qualcomm dispatch library or compiler plugin (kDispatchLibraryDir / kCompilerPluginLibraryDir), then in the system library search path. Skel libraries use GetDspSkelDir(), falling back to the QNN library directory and then the plugin directory. |
Either place all libLiteRtDispatch_Qualcomm.so, libQnn*.so, and libQnnHtpV*Skel.so files in one shared npu/ directory, or pass separate directories using QualcommOptions::SetQnnLibDir(...) and SetDspSkelDir(...). |
On macOS and iOS, place libLiteRt.dylib and libLiteRtMetalAccelerator.dylib
next to your executable (resolved with @loader_path as shown in the CMake
example above) or in your app bundle's Frameworks directory.
Example: Configure Qualcomm NPU acceleration in C++
#include "litert/cc/litert_common.h"
#include "litert/cc/litert_compiled_model.h"
#include "litert/cc/litert_environment.h"
#include "litert/cc/litert_environment_options.h"
#include "litert/cc/litert_macros.h"
#include "litert/cc/litert_options.h"
#include "litert/cc/options/litert_qualcomm_options.h"
// 1. Configure Environment (required for NPU dispatch and on-device JIT)
std::vector<litert::EnvironmentOptions::Option> env_opts = {
{litert::EnvironmentOptions::Tag::kDispatchLibraryDir, dispatch_dir},
{litert::EnvironmentOptions::Tag::kCompilerPluginLibraryDir, plugin_dir},
};
LITERT_ASSIGN_OR_RETURN(
auto env,
litert::Environment::Create(litert::EnvironmentOptions(
litert::Span<const litert::EnvironmentOptions::Option>(
env_opts.data(), env_opts.size()))));
// 2. Configure hardware accelerator (NPU with CPU fallback) and backend options
LITERT_ASSIGN_OR_RETURN(auto options, litert::Options::Create());
LITERT_RETURN_IF_ERROR(options.SetHardwareAccelerators(
litert::HwAccelerators::kNpu | litert::HwAccelerators::kCpu));
// Qualcomm NPU options (HTP performance mode and optional QNN / Skel directory overrides):
LITERT_ASSIGN_OR_RETURN(auto& qnn_opts,
options.GetOptions<litert::qualcomm::QualcommOptions>());
qnn_opts.SetHtpPerformanceMode(
litert::qualcomm::QualcommOptions::HtpPerformanceMode::kBurst);
if (!qnn_lib_dir.empty()) qnn_opts.SetQnnLibDir(qnn_lib_dir);
if (!dsp_skel_dir.empty()) qnn_opts.SetDspSkelDir(dsp_skel_dir);
// 3. Create CompiledModel and I/O buffers
LITERT_ASSIGN_OR_RETURN(auto compiled_model,
litert::CompiledModel::Create(env, model_path, options));
LITERT_ASSIGN_OR_RETURN(auto input_buffers, compiled_model.CreateInputBuffers());
LITERT_ASSIGN_OR_RETURN(auto output_buffers, compiled_model.CreateOutputBuffers());
Offline NPU AOT compilation with apply_plugin_main
To compile a .tflite model ahead of time on an x86_64 Linux host using the
prebuilt apply_plugin_main binary and Qualcomm compiler plugin:
QNN_HOST_LIB=/path/to/qairt/lib/x86_64-linux-clang
LD_LIBRARY_PATH="<prebuilt_location>/linux_x86_64:${QNN_HOST_LIB}" \
<prebuilt_location>/linux_x86_64/apply_plugin_main \
--cmd=apply \
--model=model.tflite \
--soc_manufacturer=Qualcomm \
--soc_model=SM8650 \
--libs=<prebuilt_location>/linux_x86_64 \
--qualcomm_qnn_lib_dir="${QNN_HOST_LIB}" \
--o=model_sm8650_aot.tflite
Use with coding agents
litert_cc_sdk includes a bundled agent skill at
litert_cc_sdk/skills/litert-cc-sdk-prebuilt-onboarding/ with complete CMake
templates, cross-compilation toolchains, and NPU troubleshooting guides. The
skill follows the open Agent Skills standard and
works with coding agents that support it, such as
Google Antigravity.
To enable auto-discovery in your workspace, symlink or copy the skill directory
into .agents/skills/ (or your agent's project skills directory):
On Linux and macOS:
mkdir -p .agents/skills
ln -s "$PWD/litert_cc_sdk/skills/litert-cc-sdk-prebuilt-onboarding" .agents/skills/
On Windows (PowerShell):
New-Item -ItemType Directory -Force -Path .agents\skills | Out-Null
Copy-Item -Recurse -Force litert_cc_sdk\skills\litert-cc-sdk-prebuilt-onboarding .agents\skills
You can also reference the skill directly in a prompt:
@litert_cc_sdk/skills/litert-cc-sdk-prebuilt-onboarding/SKILL.md