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

Eric Schulte schulte.eric at gmail.com
Wed Jul 13 17:39:19 UTC 2011


Hi,

The `c:build-shared-library' solution built by calling the attached lisp
file with the following from a Makefile

   ecl -norc -shell ecl-build.lisp

has been working very well and results in a surprisingly stable OCaml
Lisp hybrid executable.

However the current solution loads required libraries (e.g., alexandria)
at runtime and depends on a local instillation of quicklisp.  Would it
be possible to compiling all dependencies into a single linked library
with no external runtime dependencies using `c:build-shared-library'?
Something like a ":monolithic t" option?

Thanks -- Eric

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecl-build.lisp
Type: application/octet-stream
Size: 881 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20110713/8ce4a8a2/attachment.obj>
-------------- next part --------------

Eric Schulte <schulte.eric at gmail.com> writes:

> 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
> problems.
>
> 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
>> *OBJECT*
>>> (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
http://cs.unm.edu/~eschulte/


More information about the ecl-devel mailing list