Common Lisp FFI wrapper for libSDL2.

Upstream URL


Attila Lendvai


BSD or Bugroff



It's a Common Lisp FFI for (SDL2).


The alternative projects are partial, while this one uses cffi/c2ffi to automatically generate the complete CFFI bindings for the various subsystems of SDL2.

It only requires vanilla CFFI when used, no extra dependencies.


Written by


The primary communication channel is the facilities on the project's GitHub page.


This project uses CFFI/C2FFI, whose ASDF extension does two things:

  1. When needed, it can invoke c2ffi

to process a C header file and emit a c2ffi spec file (a json file) that contains every detail needed to generate an FFI for a given platform. But yours truely has run this phase, and checked in the resulting spec files into the c2ffi-spec/ directory. This way users don't need to have a working c2ffi executable, nor the SDL dev headers installed.

  1. Based on the above mentioned spec file, it generates the CFFI forms

into a lisp file (placed next to the spec file), and continues as if it was just another lisp file written by hand. (These lisp files could also be committed into the repo, but for now they are not, because their regeneration is automatic and painless.)

Regenerate the spec files

This should only be done when the SDL API has some new functionality that is needed on the Lisp side. Once the *.spec files got regenerated, they should be pushed into the git repo; i.e. the users of hu.dwim.sdl shouldn't need to do this normally.

On Debian

This should work, assuming that you have a working c2ffi in the path:

sudo apt-get install curl sbcl libsdl2-dev
rm -f c2ffi-spec/*.spec && ./bin/

On NixOS

$ nix-shell --pure
$ rm -f c2ffi-spec/*.spec && ./bin/


It contains a complete FFI for sdl.h, sdl-gfx.h, sdl-ttf.h, and sdl-image.h. Not much has been added yet to lispify the SDL API, but the CFFI binding part is complete.

Dependencies (6)

  • alexandria
  • cffi
  • hu.dwim.asdf
  • hu.dwim.def
  • hu.dwim.defclass-star
  • hu.dwim.syntax-sugar

Dependents (1)

  • GitHub
  • Quicklisp