2.1 Define the ffi library

(define-ffi-library SYMBOL NAME). Used to define a function that lazily loads a library.

(define-ffi-library
  test.so
  (expand-file-name
   (file-name-concat default-directory "build" "tests" "test.so")))

ffi-module’ uses ‘libltdl’ (from ‘libtool’), which will automatically supply the correct extension if none is specified, so it’s generally best to leave off the .so. The library name is usually sufficient, but on a Mac, I find I have to use the full path sometimes.