1.3. Building standalone executables

To build an executable you need a working ECL image with the compiler. The function to build customized images is c::build-program. The description of this function is as follows. Care should be taken that image-name differs from any filename in lisp-files.

 Function: c:build-program {image-name &key lisp-files ld-flags prologue-code epilogue-code}

This function builds a lisp image up from the core lisp library, plus all components listed in lisp-files. Each component is either:

  • A symbol: Names a statically linked library built from lisp code.

  • A string: Denotes an object file built from lisp code.

ld-flags is a list of strings with additional parameters to be passed to the linker. You can include here your favorite C/C++ libraries.

prologue-code and epilogue-code are used to customize the initialization process of the lisp image. In order to build the executable, c:build-program first writes down a piece of C code which initializes the lisp environment. You can customize the initialization process by suppling code to be executed before (prologue-code) or after (epilogue-code) setting up the lisp environment. Typically prologue-code defaults to an empty string, while epilogue-code invokes the classical lisp top-level. Additionally, as a convenience, epilogue-code can be either a string with C code or also a list with a lisp form, which will be interpreted at run time.