If you’re working on integrating Dart into another system—like a native mobile app, an embedded environment, or a game engine—you might need Dart compiled as a shared library. While Dart doesn’t officially distribute its engine as a shared object, it is possible to build one yourself.

In this guide, we’ll walk through the steps to build the Dart SDK as a shared library (.dylib, .so, or .dll, depending on your platform). We will compile Dart SDK to Shared Library for JIT mode.

🛠 Prerequisites

Make sure you have the following installed:

  • Python 3
  • Git
  • macOS/Linux/Windows development environment
  • Xcode + command line tools (macOS)
  • Android NDK (for Android targets)
  • Admin/root access (required for some steps)

🚚 Install depot_tools

depot_tools is a collection of tools required to work with Chromium-related projects (Dart included).

Follow the official guide:

👉 Depot Tools Setup Guide

TL;DR

Clone depot_tools

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="$PWD/depot_tools:$PATH"

Add it to your shell config (.bashrc, .zshrc, etc.) for convenience.

📦 Fetch the Dart SDK

Create a directory for the Dart SDK and fetch its source using the fetch tool:

mkdir dart-sdk
cd dart-sdk

Fetch Dart SDK source code

fetch dart

⚠️ On Windows, make sure you’re running this in a shell with Administrator privileges.

This step will take some time as it pulls a lot of source code and dependencies.

Note for Android Builds 🤖

If you’re targeting Android, you need to manually enable downloading Android dependencies:

Open the .gclient file located in the root of your dart-sdk folder.

Add the following JSON to it:

"custom_vars": {
  "download_android_deps": True,
}

Final example file should look like this:

solutions = [
  {
    "name": "sdk",
    "url": "https://dart.googlesource.com/sdk.git",
    "deps_file": "DEPS",
    "managed": False,
    "custom_vars": {
      "download_android_deps": True,
    },
    "custom_deps": {},
  },
]

After editing .gclient, run:

gclient sync

🧱 Build the Dart Engine as a Shared Library

With everything set up, you can now compile the shared library:

cd sdk

Build the shared library for macOS ARM64

./tools/build.py \
  --arch=arm64 
  runtime/engine:dart_engine_jit_shared \
  --mode release

or for Android

./tools/build.py \
  --arch=arm64 
  --os=android \
  runtime/engine:dart_engine_jit_shared \
  --mode release

Notes:

--arch=arm64: Target architecture (change as needed).

(for x64 CPU use --arch=amd64)

--os=android: Target OS (mac, ios, android, linux, win).

--mode release: Use release mode (faster, optimized).

You can also build for your host platform by changing the flags.

📁 Locate the Output

If you’re on macOS and targeting Android ARM64, your resulting shared library will be:

dart-sdk/sdk/xcodebuild/ReleaseARM64/libdart_engine_jit_shared.dylib

For other platforms, it will likely be in a similar directory under:

<root>/out/<build_dir>/

Depending on your platform, the file will be named:

libdart_engine_jit_shared.dylib (macOS)

libdart_engine_jit_shared.so (Linux/Android)

dart_engine_jit_shared.dll (Windows)

✅ Final Thoughts

Now you have a shared Dart engine library that can be embedded into other native applications. This opens up powerful use cases—embedding Dart in game engines, building custom scripting systems, or integrating Dart into native mobile apps with complete control.

If you need help embedding or invoking Dart code from your app, feel free to reach out or stay tuned for a follow-up post.