Question

I just started with common-lisp, having come from C++ and Python. I'm trying to run a simple SDL program that does nothing other than show an image on-screen. I can get it working from within SLIME. The problem is, it won't work when run from the shell as a script.

My program looks like this:

#!/usr/bin/sbcl --script

(asdf:operate 'asdf:load-op :lispbuilder-sdl)

(defun main ()
  (sdl:with-init ()
    (sdl:window 320 240)
    (sdl:draw-surface (sdl:load-image "image.png"))
    (sdl:update-display)
    (sdl:with-events ()
      (:quit-event () t)
      (:video-expose-event () (sdl:update-display)))))

(main)

When I run this as a script, I get the following error:

mkg@chisel:~/projects/common-lisp/sandbox$ ./hello-world.lisp 
unhandled ASDF:MISSING-COMPONENT in thread #<SB-THREAD:THREAD "initial thread" RUNNING {AA5E849}>:
  component "lispbuilder-sdl" not found

0: (SB-DEBUG::MAP-BACKTRACE #<CLOSURE (LAMBDA #) {AAF1EF5}>)[:EXTERNAL]

(... long backtrace omitted)

Oddly, this program works fine if I do the following. I open the program in Emacs, start SLIME in another window, and in the SLIME window, I enter the first line of the program:

(asdf:operate 'asdf:load-op :lispbuilder-sdl)

Then, in the editor window, I hit C-c C-k (compile/load file). This pops up a window showing image.png, as expected.

Why does this not work when run as a shebang script? How can I fix it?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top