[Ecls-list] Loading object files

Juan Jose Garcia-Ripoll Juan.Ripoll at mpq.mpg.de
Sun Jan 6 01:30:01 UTC 2002

"Dr. Edmund Weitz" wrote:
> I understand that I can embed C source code directly into ECL. I
> wonder if it's also possible to load and use already-compiled object
> files or libraries dynamically - something like CMUCL's

If you work on a platform that supports dlopen (See #+dlopen feature)
then you can du with c::build-shared-library the same as you do with
c::build-program. THe syntax of the function (found in
ecldev.{info,html}) is

c:build-shared-library library-name &key lisp-files prologue-code
epilogue-code ld-flags 
This function builds a library file up from the object files listed in
lisp-files. Each of the arguments to lisp-file must name a single object
file produced with compile-file. 

library-name is the physical pathname corresponding to the library. The
value of library-name must follow some system-specific conventions. To
make your program portable, library-name should be built using the
output of c:library-pathname. prologue-code and epilogue-code are
strings with C code to be executed before and after initializing the
library, respectively. For dynamically linked libraries you can also
provide a list of strings in ld-flags. These strings are additional
parameters for the linker and their purpose is to link C/C++ extensions
into the library. 

So, in LISP-FILES you should put the name of a compiled file that
includes a few wrappers for the functions you intend to call, and in
LD-FLAGS you should list the names of the object files or libraries that
you need to load.

There is nothing like ALIEN:LOAD-FOREIGN yet. In other words, you always
have to write wrappers and compile them -- you cannot build these things
dynamically. (Well, one could, using some assembler, but this is far
from my list of priorities right now, and it would not be very


More information about the ecl-devel mailing list