5 releases

Uses new Rust 2024

new 0.1.4 Mar 5, 2026
0.1.3 Mar 4, 2026
0.1.2 Mar 4, 2026
0.1.1 Mar 2, 2026
0.1.0 Mar 1, 2026

#132 in FFI

Zlib license

6MB
61K SLoC

sdl-sys-rs

Rust FFI bindings for SDL3 and its satellite libraries (SDL3_image, SDL3_mixer, SDL3_ttf), generated with bindgen.

Workspace Crates

Crate Purpose
sdl-sys Raw FFI bindings for SDL3
sdl-image-sys Raw FFI bindings for SDL3_image
sdl-mixer-sys Raw FFI bindings for SDL3_mixer
sdl-ttf-sys Raw FFI bindings for SDL3_ttf
sdl3-gfx-sys Raw FFI bindings for SDL3_gfx
sdl-main Idiomatic Rust wrapper for SDL's callback-based app loop
sdl-bindgen Binding generator (developer tool, not published)
sdl-build-helper Shared build script logic for -sys crates

Getting Started

Prerequisites

  • Rust (edition 2024)
  • SDL3 shared libraries installed system-wide (or reachable via LD_LIBRARY_PATH)
  • Clang (required by bindgen)

Clone with Submodules

git clone --recurse-submodules https://github.com/achusbyr/sdl-sys-rs.git
cd sdl-sys-rs

If you already cloned without submodules:

git submodule update --init --recursive

Regenerate Bindings (optional)

Only needed if you update the SDL submodules or want to add a new target:

cargo run -p sdl-bindgen

This reads the C headers from submodules/ and writes generated Rust files into each crate's src/generated/ directory.

Build

cargo build

Run Examples

cargo run -p sdl-sys --example hello_world
cargo run -p sdl-main --example callbacks

Adding a New Target

  1. Add the target triple to TARGETS in sdl-bindgen/src/main.rs
  2. Run cargo run -p sdl-bindgen
  3. The new bindings will be generated with appropriate #[cfg] attributes

Dependencies