[Ecls-list] Link .o or .so to a running ECL program

Matthew Mondor mm_lists at pulsar-zone.net
Wed Oct 1 18:55:22 UTC 2014


On Wed, 01 Oct 2014 12:00:54 -0300
"José Roberto B. de A. Monteiro" <jordeam at gmail.com> wrote:

> I am wondering if it is possible to link a pure C compiled file, in .o
> or .so (or .dll) formats, into a running Lisp process and how I can do that.
> 
> The case is a am running ECL via Emacs+Slime and it would be very useful
> to link some modules written in C to bind then via uffi or native ffi.

It is possible to load dynamically linked libraries using the
ffi:load-foreign-library function (which internally uses dlopen(3)).

CFFI probably also has a wrapper equivalent, but I personally have less
experience with CFFI than with the ECL native FFI (and more experience
with the native C-inline ECL FFI than with the ECL UFFI compatibility
layer) but these would be your FFI options.  If you want to produce
bindings for a library in an implementation-agnostic way, I agree with
pjb that you should use CFFI today.

It is also possible to link compiler-objects together when producing
an ECL executable, using: "ecl -o <destination> -link <objects>".  These
objects may include ones created from CL files using: "ecl -o
<destination>.o -s -compile <source>.lisp", as well as objects created
from C files using "cc -o <destination>.o -c <source>.c".

-- 
Matt




More information about the ecl-devel mailing list