[Ecls-list] using built library files in C program

Michael Hannemann hannemann at inetmi.com
Mon Apr 7 13:25:14 UTC 2003


Juan Jose Garcia Ripoll wrote:
>No, what I mean is that when you execute BUILD-PROGRAM, a small C file
>is created which initializes both your library and the lisp
>system.
>
>I have appended a small modification to ecl/src/cmp/cmpmain.lsp, so
>that if you follow the example for BUILD-PROGRAM you will see what
>output ECL produces.
>
>In a few words, what you have to do:
>1) Create the example hello.lsp program (Whatever you want inside)
>2) Compile hello.lsp
> > (compile-file "hello.lsp" :system-p t)
>3) Link everything together
> > (c:build-program "myecl" :lisp-files '("hello.o"))
>4) Inspect the output.
>
>Basically, what ECL output is a sequence like
>
>int main(int argc, char **argv) {
>     /* prologue code */
>     ...
>     /* initialize lisp and your library */
>     cl_boot(argc, argv);
>     read_VV(OBJNULL, init_HELLO);
>     /* epilogue code */
>     ...
>}
>
>But I am writing this without trying it, so you'd better follow the
>steps I mentioned above :-)
>
>BTW, libraries to be linked against standalone programs should be
>compiled with :SYSTEM-P T, in order to produce *.O object files,
>and not DLLs.

Beautiful!  I patched, rebuilt, and tried it out, and that was exactly what 
I needed!  Great!  Now I just need to build something bigger than a toy 
example.  =)

On my linux machine, what I did was use ECL to build a shared library out 
of my .o file, and then linked against it and ran.  One thing I had to do, 
though, was manually put "lib" in front of the library name so that the gcc 
linker would find it.  Should this part be necessary?

Off to see how much of my code runs in ECL,
Thanks again,

Michael





More information about the ecl-devel mailing list