[Ecls-list] calling ECL functions defined in an ASDF package from C code

Eric Schulte schulte.eric at gmail.com
Sat Jun 25 22:24:28 UTC 2011

Juan Jose Garcia-Ripoll <juanjose.garciaripoll at googlemail.com> writes:

> On Sat, Jun 25, 2011 at 8:48 PM, Eric Schulte <schulte.eric at gmail.com>wrote:
>> Thank you, such an interface sounds ideal.  Do you have any idea of a
>> time scale for such an implementation, e.g., on the order of days weeks
>> or months?
> I just finished the following patch:

Wow, I should have included hours and minutes in my orders of magnitude
for implementation ETA.

Thanks for the quick implementation, I'll begin using this new
functionality immediately and get back to you if I run into any

Cheers -- Eric

>  - When building shared and statically linked libraries, ECL creates
>  an extra function that performs two tasks: initializing ECL if it
>  wasn't done before, and initializing the library. This can be used to
>  create standalone libraries to be linked with other programs. The
>  name of the function typically begins with main_dll or main_lib but
>  it is output by ECL on screen.
> An example is shown below. It has been uploaded to CVS/git but it might not
> be functioning perfectly because of other issues -- namely the thing with
> compiled data mentioned on a separate thread, which is still under testing.
> Feel free to report problems. Best,
> Juanjo
> $ ecl -norc
> ECL (Embeddable Common-Lisp) 11.1.1
> Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
> Copyright (C) 1993 Giuseppe Attardi
> Copyright (C) 2000 Juan J. Garcia-Ripoll
> ECL is free software, and you are welcome to redistribute it
> under certain conditions; see file 'Copyright' for details.
> Type :h for Help.
> Top level.
>> (si::system "cat foo.lsp")
> (defun foo (x)
>  (print x))
> 0
>> (defparameter *object* (compile-file "foo" :system-p t :verbose nil))
> ;;; Loading #P"/Users/jjgarcia/lib/ecl-11.1.1/cmp.fas"
> ;;; Compiling (DEFUN FOO ...).
> ;;; Emitting code for FOO.
> ;;; Note:
> ;;;   Invoking external command:
> ;;;   gcc -I. -I/Users/jjgarcia/include/ -g -O2 -fPIC -fno-common -Ddarwin
> -O2 -w -c foo.c -o foo.o
>> (c:build-shared-library "foo" :lisp-files (list *object*))
> ;;; Note:
> ;;;   Library initialization function is main_dll_FOO
> [...]
> In this case
> main_dll_FOO(int argc, char **argv);
> is the initialization routine of the library. Note that this calls cl_boot()
> but _you_ should manually insert a call to cl_shutdown() somewhere in your
> program.
> Juanjo

Eric Schulte

More information about the ecl-devel mailing list