[cffi-devel] Re: support for .a libraries

Alexis Gallagher public at alexisgallagher.com
Fri Jan 20 15:52:59 UTC 2006


Stephen Compall wrote:
> On Fri, 2006-01-20 at 05:23 +0000, Alexis Gallagher wrote:
>> I was wondering if define-foreign-library can currently handle libraries 
>> that are in the "ar" archive format.
> 
> I recommend that you obtain a .so version of your library.  For help
> with this, I suggest contacting the library's maintainer(s).
> 

I found a better solution -- actually, Hans on the #lisp IRC channel 
handed me a better solution. My library file was "libRNA.a". I wanted 
access to the function "fold". You can use the ld linker's -u argument 
to generate a shared object file that includes any symbol and its 
dependencies. So the following command produced the file libRNA.so file 
that I needed for CFFI

% ld -u fold -shared -o libRNA.so libRNA.a

CFFI loaded and ran libRNA.so successfully on the first try.

By the way, I also wrapped a C function which returned its string output 
values through a pointer argument. This is a common requirement, but I 
know it can be painful if you're using SWIG, a wrapper generator used 
for python and other dynamic languages, or simply if you're new to 
bridging languages. The CFFI documentation doesn't given an example of 
it. Do you or others know, is there a wiki or someplace one could 
contribute hints and examples for useful but elementary cases like this?

Right now, the libcurl example in the documentation is thorough but for 
many cases it might be faster and clearer also to have a "cookbook" 
style set of examples.

cheers,
alexis




More information about the cffi-devel mailing list