Fasttrack to 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.
# — 11 June, 2004