LiteRT Prerequisites: Complete Setup Guide for Linux, macOS, and Windows

LiteRT requires Docker for the simplest universal setup, or platform-specific toolchains including Bazelisk, Python 3, and LLVM/Clang on Linux; Xcode Command Line Tools and Homebrew on macOS; and Visual Studio 2022 with configured environment variables on Windows.

The google-ai-edge/LiteRT repository provides a lightweight runtime for machine learning inference, but before you can compile the C++ libraries or run the benchmark tools, you must satisfy specific LiteRT prerequisites that vary by target platform. Whether you are building for Android mobile devices or desktop deployments, the build system relies on Bazel and requires precise toolchain configurations documented in the source repository.

Universal LiteRT Prerequisites: Docker Method

For a hermetic build environment across all platforms, the LiteRT project provides a Docker-based solution that eliminates manual dependency management. According to docker_build/README.md, the only universal prerequisites are Docker and optionally Docker Compose for container orchestration.

The repository includes docker_build/build_with_docker.sh, which automates the entire environment setup including Bazel 7.4.1, Android SDK/NDK, and sample builds:


# From the repository root

./docker_build/build_with_docker.sh

This script creates an Ubuntu-based container with all necessary dependencies pre-installed, making it the recommended "one-click" method for developers who want to avoid configuring local toolchains.

Platform-Specific LiteRT Prerequisites

If you prefer native compilation or require custom toolchain configurations, you must install platform-specific dependencies as detailed in g3doc/instructions/BUILD_INSTRUCTIONS.md.

Linux Build Requirements

Building LiteRT on Linux requires Bazelisk as the recommended Bazel launcher, along with standard build tools and specific compiler versions. The documentation in g3doc/instructions/BUILD_INSTRUCTIONS.md specifies OpenJDK 17, Python 3, and LLVM/Clang 18 with libc++ and libc++abi.

Install the dependencies on Ubuntu/Debian systems:

sudo apt-get update && sudo apt-get install -y build-essential curl git openjdk-17-jdk \
    python3 python3-pip python3-dev unzip wget llvm-18 clang-18 libc++-dev libc++abi-dev

After installing prerequisites, generate the Bazel configuration and build the compiled model API:

git clone https://github.com/google-ai-edge/LiteRT.git
cd LiteRT
./configure
bazel build //litert/cc:litert_compiled_model
bazel build //litert/tools:benchmark_model

The ./configure script generates .litert_configure.bazelrc, which contains platform-specific build flags required for subsequent Bazel commands.

macOS Build Requirements

For macOS development, LiteRT requires Xcode Command Line Tools and Homebrew for package management. The build instructions specify Python 3.11 installed via Homebrew to ensure compatibility with the Bazel build rules.

Install the prerequisites and build for your architecture:

xcode-select --install
brew install python@3.11

Build for Apple Silicon:

bazel build --config=macos_arm64 //litert/cc:litert_compiled_model

Or for Intel Macs:

bazel build --config=macos_x86_64 //litert/cc:litert_compiled_model

Windows Build Requirements

Windows builds require Visual Studio 2022 with the C++ workload installed, Git for Windows (which provides Bash), and Python 3.13. You must also configure specific Bazel environment variables so the build system can locate the compiler.

Set the required environment variables in PowerShell:

[System.Environment]::SetEnvironmentVariable("BAZEL_VC", "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC", "User")
[System.Environment]::SetEnvironmentVariable("BAZEL_SH", "C:\Program Files\Git\bin\bash.exe", "User")

Create a .bazelrc.user file with the Windows configuration and build:

git clone https://github.com/google-ai-edge/LiteRT.git
cd LiteRT
@"
build --config=windows
"@ | Out-File -Encoding ASCII .bazelrc.user

bazel build //litert/cc:litert_compiled_model
bazel build --define=protobuf_allow_msvc=true //litert/tools:benchmark_model

The BAZEL_VC variable points to the Visual C++ compiler tools, while BAZEL_SH specifies the path to Bash for shell script execution during the build process.

Android Development Prerequisites

Cross-compiling LiteRT for Android requires a Linux, macOS, or Windows host with Android SDK (API level 21 or higher) and Android NDK (revision 21 or higher) installed. While Android Studio is optional for sample app development, the command-line tools are mandatory for Bazel builds.

As documented in g3doc/instructions/BUILD_INSTRUCTIONS.md, ensure your ANDROID_SDK and ANDROID_NDK_HOME environment variables point to valid installations before running ./configure.

Summary

  • Docker provides the simplest hermetic build environment for all platforms, requiring only Docker itself as a prerequisite.
  • Linux builds require Bazelisk, OpenJDK 17, Python 3, and LLVM/Clang 18 with libc++ libraries.
  • macOS builds require Xcode Command Line Tools, Homebrew, and Python 3.11, with architecture-specific Bazel configs.
  • Windows builds require Visual Studio 2022, Git for Windows, Python 3.13, and specific BAZEL_VC and BAZEL_SH environment variables.
  • The ./configure script generates .litert_configure.bazelrc, which is required for all native builds.
  • Android targets require SDK API 21+ and NDK r21+ regardless of host platform.

Frequently Asked Questions

Do I need Docker to build LiteRT?

No, Docker is optional but recommended as the fastest setup method. The docker_build/build_with_docker.sh script creates a complete Ubuntu-based build environment with all dependencies pre-installed. If you prefer native compilation, you can install the platform-specific toolchains described in g3doc/instructions/BUILD_INSTRUCTIONS.md.

What Bazel version does LiteRT require?

The Docker build script installs Bazel 7.4.1, and the documentation recommends using Bazelisk for Linux builds to automatically manage Bazel versions. While specific version requirements may vary by release, the build configuration files in the repository target Bazel 7.x.

Can I build LiteRT for Android on Windows?

Yes, LiteRT supports Android builds from Windows hosts, provided you install the Android SDK (API 21+) and Android NDK (r21+) alongside the standard Windows prerequisites including Visual Studio 2022. Configure the ANDROID_SDK and ANDROID_NDK_HOME environment variables before running ./configure.

Is Python required for all LiteRT builds?

Yes, Python is required across all platforms, though specific version requirements vary. The documentation specifies Python 3.11 for macOS via Homebrew, Python 3.13 for Windows, and general Python 3 with pip for Linux. Python is used for build scripting and generating the Bazel configuration files.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →