How to use quicklisp when CL program is invoked as a shell script?

放肆的年华 提交于 2019-12-02 22:56:25

Creating a dedicated version of core image is a good option. You may:

  1. load quicklisp and sb-ext:save-lisp-and-die in a new image. You write a shell/bat script named, say qlsbcl, like this:

    sbcl --core <my-new-image-full-path-location> "$@"
    
  2. grab clbuild2 at http://gitorious.org/clbuild2 and run clbuild lisp. You'll have to symlink clbuild to a binary directory in your path and tweak some scripts a bit if your quicklisp is not in the common place ~/quicklisp (https://gist.github.com/1485836) or if you use ASDF2 (https://gist.github.com/1621825). By doing so, clbuild create a new core with quicklisp, ASDF and anything you may add in conf.lisp. Now the shebang may look like this:

    #!/usr/bin/env sbcl --noinform --core <my-clbuild-install-directory>/sbcl-base.core --script
    

The advantage of clbuild is that you may easily create and manage core and quicklisp installation from shell for sbcl (by default) or any other modern CL like ccl64 implementation. Mixing the two techniques (script and clbuild) will solve your problem.

You are doing everything right.

Basically, before you can use quicklisp, you need to load it (currently, it's not bundled with SBCL, although it may change in the future). There are various ways to do it. For example, you can load your .sbclrc with the quicklisp init:

#!/usr/bin/sbcl --script
(load ".sbclrc")
(load "my-program.lisp")
(in-package :my-package)
(my-main-method)

or just paste those lines in your script, like you have suggested.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!