Home/docs/guide/Linux integration
Linux integration
Linux / X11 / Wayland / WSLg
Linux support remains experimental, with x86_64 and ARM64 prebuilt bundles now available in bundled and system modes. Rust, C/C++, and Flutter hosts render through X11 or Wayland and output audio through PulseAudio. HDR surfaces and direct VA-API import remain experimental.
Prebuilt bundles#
All four archives are built on Ubuntu 22.04 / glibc 2.35, with maximum requirements GLIBCXX_3.4.30 and CXXABI_1.3.13. Ubuntu 26.04 is not required.
| CPU | bundled | system |
|---|---|---|
| x86_64 | erika-capi-linux-x64-bundled.zip | erika-capi-linux-x64-system.zip |
| ARM64 | erika-capi-linux-arm64-bundled.zip | erika-capi-linux-arm64-system.zip |
bundled statically embeds FFmpeg, dav1d, zlib, patched libass and font libraries, but still needs system libc/libstdc++, PulseAudio, Fontconfig, VA-API/DRM, the Vulkan loader and GPU drivers. system uses FFmpeg 8 and font shared libraries; patched libass and SoundTouch remain embedded.
The system mode needs ABI-compatible shared libraries, not just an ffmpeg executable: avdevice/avformat/avcodec 62, avfilter 11, swresample 6, swscale 9, and avutil 60. Read each archive’s DEPENDENCIES.txt, use its matching erika.h, and verify the download against SHA256SUMS.
Alternative: source build with system libraries#
The following commands are for Ubuntu 26.04. Rust 1.92+ is required. The older FFmpeg in the default Ubuntu 22.04 and 24.04 repositories does not satisfy this build path.
Ubuntu 26.04
sudo apt update sudo apt install -y \ build-essential pkg-config clang libclang-dev rustc cargo rustfmt \ curl ca-certificates meson ninja-build patch xz-utils python3 \ libavdevice-dev libavfilter-dev libavformat-dev libavcodec-dev \ libswresample-dev libswscale-dev libavutil-dev \ libfreetype-dev libharfbuzz-dev libfribidi-dev libfontconfig-dev \ libpulse-dev libx11-dev libwayland-dev libxkbcommon-dev \ libxkbcommon-x11-0 libvulkan-dev mesa-vulkan-drivers libegl1 \ libgl1-mesa-dri fonts-dejavu-core pulseaudio-utils
On PipeWire desktops, enable pipewire-pulse. You can check the audio connection with pactl info. WSLg already provides a PulseAudio service.
Build and run#
shell
git clone https://github.com/AimesSoft/liberika.git cd liberika git checkout v0.3.8 bash scripts/build_linux_libass.sh cargo build --locked --release -p linux_native_demo -p erika_capi cargo run --locked --release -p linux_native_demo -- /path/to/video.mkv
libass uses liberika's patched version of 0.17.5; the build script downloads it, verifies it, and applies the font fallback patch. FFmpeg 8 and PulseAudio link dynamically against system libraries by default. Build outputs are in target/release/.
The demo selects the window protocol automatically; you can also pass --x11 or --wayland. Press Space to pause or resume, the left and right arrow keys to seek 5 seconds, and Esc to exit.
Flutter integration#
After extracting a prebuilt archive, point ERIKA_LIBRARY_DIR at its absolute lib/ path. The Linux plugin does not download archives automatically. Add erika_flutter: ^0.3.8 to the host.
shell
export ERIKA_LIBRARY_DIR=/absolute/path/to/extracted/lib flutter build linux --release
ErikaVideoView / ErikaTextureVideoView use an SDR RGBA texture with Flutter clipping and overlays, but require per-frame GPU readback. On Wayland, ErikaWindowOverlayVideoView places native video below transparent Flutter UI through wl_subsurface to reduce readback. Leave the video area transparent. This native layer supports opaque srcOver compositing, and the video itself does not support Flutter clipping or color filters. X11 uses the texture views.
Rust and C/C++ integration#
A Rust host enables the wgpu feature of erika. A C host links liberika_capi.so and uses the erika.h from the same build.
| surface kind | raw_window | raw_display |
|---|---|---|
| ErikaWgpuSurfaceKind_XlibWindow | X11 Window integer ID | Display* |
| ErikaWgpuSurfaceKind_WaylandSurface | wl_surface* | wl_display* |
Attach a window with erika_presenter_attach_wgpu_surface. Convert pointers to uint64_t through uintptr_t, and pass the width and height in physical pixels. Release the window and display only after detach completes or the presenter is destroyed. Run attach, render, resize, and detach for the same presenter serially on the window event thread.
Call order: create → attach → open → play → render_tick → close → detach → destroy. A runnable C example is at examples/linux_native_demo/capi_smoke.c.
External Rust workspaces#
External Rust workspaces must add the HAL patch to their own root Cargo.toml. Cargo does not inherit a dependency’s [patch.crates-io]; Vulkan direct import needs the patch to preserve external image contents. Pin the dependency and patch to the same tag or commit:
Cargo.toml
[dependencies]
erika = { git = "https://github.com/AimesSoft/liberika", tag = "v0.3.8", features = ["wgpu"] }
[patch.crates-io]
wgpu-hal = { git = "https://github.com/AimesSoft/liberika", tag = "v0.3.8" }If an existing lockfile still selects the registry HAL, run cargo update -p wgpu-hal --precise 29.0.3, verify the source with cargo tree -i wgpu-hal, and commit Cargo.lock. Linux consumers also need PIC settings in their own .cargo/config.toml: soundtouch-ffi disables PIC by default, and dependency repositories’ .cargo settings do not propagate:
.cargo/config.toml
[env] CFLAGS_x86_64_unknown_linux_gnu = "-fPIC" CXXFLAGS_x86_64_unknown_linux_gnu = "-fPIC" CFLAGS_aarch64_unknown_linux_gnu = "-fPIC" CXXFLAGS_aarch64_unknown_linux_gnu = "-fPIC"
Decoding and the GPU path#
On Linux, liberika tries NVIDIA NVDEC first, then Intel / AMD VA-API. If the driver or format is not supported, it falls back to FFmpeg software decoding.
shell
export ERIKA_HWDEC=auto # auto / cuda / nvdec / vaapi / software # On multi-GPU machines you can pick a device: export ERIKA_CUDA_DEVICE=0 export ERIKA_VAAPI_DEVICE=/dev/dri/renderD128
The regular NVDEC path downloads the decoded planes and then uploads them to wgpu. Direct import from VA-API to Vulkan is experimental. Linux HDR requires the compositor to actually provide an FP16 extended-linear WSI surface; Flutter RGBA texture output is SDR.
WSLg#
shell
bash scripts/run_wsl_gpu.sh --wayland /mnt/c/path/to/video.mkv # Or with X11: bash scripts/run_wsl_gpu.sh --x11
The launch script selects wgpu → OpenGL/EGL → Mesa D3D12 for the liberika process. WSL uses the Windows GPU driver, so you do not need to install a Linux NVIDIA kernel driver. If the repository is under /mnt/c, put CARGO_TARGET_DIR on the Linux filesystem to speed up builds.
Verification#
shell
bash scripts/check_linux.sh # Also check Wayland: ERIKA_TEST_WAYLAND=1 bash scripts/check_linux.sh
The check requires working display and audio services. It covers play, pause, seek, resize, and the C ABI lifecycle.