Let’s say we have code like this:
(defpackage :app (:use :cl) (:export :main)) (in-package :app) (defun main () 3)
This is supposed to work like this:
cl-launch --lisp sbcl --system app --dump app-image cl-launch --image app-image --init '(app:main)' -o app
using the same system definition listed below.
You can use various CL implementations.
In SBCL it’s something like:
(require 'asdf) (asdf:operate 'asdf:load-op :app) (sb-ext:save-lisp-and-die "program" :executable t :toplevel 'app:main)
with usage of
(defsystem :app :name "app" :components ((:file "app")))
The output is rather big in the time of writing,
gzexe may compress it but startup will take a little longer.
In ECL it’s done along the lines of:
(compile-file "program.lisp" :system-p t) (c:build-program "program" :lisp-files '("program.o") :epilogue-code '(ext:quit (app:main)))
Epilogue code starts the main and quits with return code instead of starting REPL. Program is really small but it depends on
libecl shared library.