I performed a small experiment, trying to track down a bug in a Common Lisp package that I'm porting to OpenMCL. I realized that some of my steps for tracking this down would probably make for a super simple tutorial on using UFFI
First, make a quick C library
lib.c:
#include <stdio.h>
int teststuff(int i) {
return i;
}
Now compile it:
$ gcc -g -c -dynamiclib -o lib.o lib.c
Now build a dynamic library:
$ libtool -dynamic -o lib.so lib.o -lc
Use
ASDF to install
UFFI
Now create a simple Lisp program that calls your function
test-uffi.lisp:
(asdf:operate 'asdf:load-op :uffi)
(uffi:load-foreign-library #p"/Users/stevej/lib.so" :supporting-libraries '("c"))
(uffi:def-function "teststuff" ((hello :int)) :returning :int)
(teststuff 1)
Voila, your first UFFI program.