How to properly save Common Lisp image using SBCL?

て烟熏妆下的殇ゞ 提交于 2019-12-03 07:58:25

Thanks for the help from @jkiiski here is the full explanation and solution:

  1. SBCL uses extra modules (SB-SPROF, SB-POSIX and others) that are not always loaded into the image. These module reside in contrib directory located either where SBCL_HOME environment variable pointing (if it is set) or where the image resides (for example, in /usr/local/lib/sbcl/).

  2. When an image is saved in another location and if SBCL_HOME is not set, SBCL won't be able to find contrib, hence the errors that I saw.

  3. Setting SBCL_HOME to point to contrib location (or copying contrib to image location or new image to contrib location) solves the problem.

  4. Finally, about roswell: roswell parameter -m searches for images in a specific location. For SBCL (sbcl-bin) it would be something like ~/.roswell/impls/x86-64/linux/sbcl-bin/1.3.7/dump/. Secondly, the image name for SBCL must have the form <name>.core. And to start it, use: ros -m <name> -L sbcl-bin run. (Quick edit: better use ros dump for saving images using roswell as it was pointed out to me)

If you want to create executables, you could try the following:

(sb-ext:save-lisp-and-die 
  "core"
  :compression t
  ;; this is the main function:
  :toplevel (lambda () 
              (print "hell world")                                      
              0)
  :executable t)

With this you should be able to call QUICKLOAD as you wish. Maybe you want to checkout my extension to CL-PROJECT for creating executables: https://github.com/ritschmaster/cl-project

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