[Ecls-list] I do not understand how to link C modules with Lisp main prog

Moshe Goldstein goldmosh at fh.huji.ac.il
Tue Apr 1 03:43:19 UTC 2003


Juan Jose Garcia Ripoll wrote:

> On Monday 24 March 2003 18:05, Moshe Goldstein wrote:
> > In summary:
> > I wrote several Lisp functions that invoke C functions that I took from
> > an open-source package. I compiled all the C program pieces using the -c
> > -ansi options of gcc.
> > I need to link all the pieces together to build a running program.
> > The only thing I need in order to understand how to do it with ECL, is a
> > complete tiny example, or a clear explanation of how to do it.
>
> A scheme of how your linking stuff would look like:
>
> (defvar *my-c-program-prologue* "
>         /* All stuff which initializes your C libraries and registers your C
>            functions with ECL */
> ")
>
> (defvar *my-c-program-epilogue* "
>         /* When you do not want the lisp toplevel to handle the execution
>            write your own code here. Otherwise, set *my-c-program-epilogue* to
>           NIL. */
> ")
>
> (if *my-c-program-epilogue*
>   (c:build-program "myecl"
>         :lisp-files '("hello.o")
>         :ld-flags '("first-object-file.o" "second-object-file.o" "-Lf2c" ...)
>         :prologue-code *my-c-program-prologue*
>         :epilogue-code *my-c-program-epilogue*)
>   (c:build-program "myecl"
>         :lisp-files '("hello.o")
>         :ld-flags '("first-object-file.o" "second-object-file.o" "-Lf2c" ...)
>         :prologue-code *my-c-program-prologue*))
>
> 1) The PROLOGUE code is intended to perform initialization of your
> C/C++/FORTRAN/... stuff.
>
> 2) The EPILOGUE code should only be present when you want to replace the lisp
> toplevel (the interactive read-eval-execute loop) with your own routines.
>
> 3) :LD-FLAGS lists all flags to be passed to the linker. It includes your
> C/C++/FORTRAN/etc, object files, your favourite libraries, special flags,
> etc.
>
> I am sorry I cannot supply a better example, but lacking a lot of free time, I
> decided to give priority to making ECL more stable and less buggy and not so
> much to write examples. This is where other people could easily contribute
> ;-)
>
> Juanjo
>

Thank you very much.
I hope this will help me build my multi-language program the way I need it.
When I succeed to do it, I will share my experience with all of you in the list.

Thanks (muchas gracias).

-- Moshe






More information about the ecl-devel mailing list