Calling a C library from Lisp, when no package exists to do so

I talked about how one could find packages written to support linking Lisp to many popular external libraries.  But what do you do if you want to use a less prominent library, one that hasn’t been set up in that way, or if you have a privately developed C library that you want to link to your Lisp code?

This is where we make use of the CFFI for Lisp.  I’m not going to repeat how to use it, there are certainly tutorials available on the web.  You might start with this one.  My purpose here is to point out its existence and describe some of its abilities.

To put it simply, you can use CFFI to link into a shared object library which exports a C interface.  Using the library’s header file, you can create a Lisp wrapper that calls into the library, and then easily use this library in any of your Lisp projects.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


反垃圾邮件 / Anti-spam question * Time limit is exhausted. Please reload CAPTCHA.