Call C libraries from Clojure and babashka.
This library is the babashka.ffi namespace that ships inside babashka,
extracted so that JVM Clojure programs can use it too. Babashka consumes this
repository as a submodule.
Status: work in progress, not yet released.
On the JVM:
- JDK 22 or newer. The library uses the Java FFM API.
- Start the JVM with
--enable-native-access=ALL-UNNAMED, or set theEnable-Native-Accessmanifest attribute in an uberjar. Without the flag, modern JDKs warn, and a future JDK release refuses the calls.
In babashka the namespace is built in: (require '[babashka.ffi :as ffi]).
- babashka.sqlite: SQLite
- babashka.postgres: PostgreSQL through libpq
- babashka.duckdb: DuckDB
- filewatcher: file watching through FSEvents, inotify and ReadDirectoryChangesW
None of them expose an arena, a pointer, or a layout: the FFI stays inside the library.
doc/guide.md documents the API: library loading, function binding, memory, arenas, structs, callbacks, and performance limits for each host.
API.md lists every public var with its arities and docstring.
Regenerate it with bb quickdoc.
The library exports a clj-kondo hook for defcfn. Copy the config with:
clj-kondo --lint "$(clojure -Spath)" --copy-configs --skip-lint
In a babashka project, use the built-in classpath:
clj-kondo --lint "$(bb print-deps --format classpath)" --copy-configs --skip-lint
Copyright © 2026 Michiel Borkent
Distributed under the MIT License. See LICENSE.
Babashka embeds this library and is itself EPL licensed. The two licenses apply to their own repositories.