How to build Common Lisp project?

2.2k views Asked by At

I'm new to CL and I can't figure out how to build binaries from my simple project.

I've created app.asd file with following contents:

(asdf:defsystem game
  :version "0.0.1"
  :components ((:file "package")
               (:file "main")))

package.lisp contents

(defpackage :app 
  (:use :common-lisp :asdf) 
  (:export :start))

and main.lisp

(in-package :app)

(defun start (args)
  (format t "Hello"))

I've also symlinked app.asd to ~/quicklisp/quicklisp/app.asd, and when I execute

(require 'asdf)
(asdf:operate 'asdf:load-op :app)

it looks like something compiles, but I can't find binaries/object files anywhere.

How do I build my project so I can copy it to another machine without CL installed and run?

I'm using sbcl 1.1.13 and asdf 3.0.2 on osx.

1

There are 1 answers

2
Xach On BEST ANSWER

Don't put .asd files in ~/quicklisp/quicklisp/. Use ~/quicklisp/local-projects/ instead.

The syntax for your start defun is wrong. It needs a lambda list.

Common Lisp is often used by starting the environment, loading the application, and then interactively calling functions defined by your application. The load process compiles the source code to machine code and the functions you call interactively are compiled functions.

When I want to make a binary file I can run from the command line, I use buildapp. In your case, you could do something like this:

sbcl --no-userinit --no-sysinit --non-interactive --load ~/quicklisp/setup.lisp \
  --eval '(ql:write-asdf-manifest-file "systems.txt")'

buildapp --manifest-file systems.txt \
  --manifest-file ~/quicklisp/local-projects/system-index.txt \
  --load-system game \
  --entry app::start \
  --output game

In this scheme, you would have to modify app::start to accept one argument, a list containing all the command line argument strings passed to game.

In general, most Common Lisps have some way to produce a binary program to run independently of the normal runtime. The terminology varies, but it's often called "delivery". If you use a different Common Lisp in the future, you may get more information if you search the documentation for information about delivery.