Build 将公共Lisp编译为可执行文件

Build 将公共Lisp编译为可执行文件,build,common-lisp,sbcl,Build,Common Lisp,Sbcl,我最近开始使用SBCL学习CommonLisp。如何将Lisp程序编译成Windows二进制文件?使用SB-EXT:SAVE-Lisp-AND-DIE。有关详细信息,请参阅。有几种工具可以完成此操作。您可以从。生成hello.exe开始: * (defun main () (print "hello")) MAIN * (sb-ext:save-lisp-and-die "hello.exe" :toplevel #'main :executable t) [undoing binding s

我最近开始使用SBCL学习CommonLisp。如何将Lisp程序编译成Windows二进制文件?

使用
SB-EXT:SAVE-Lisp-AND-DIE
。有关详细信息,请参阅。

有几种工具可以完成此操作。您可以从。

生成hello.exe开始:

* (defun main () (print "hello"))

MAIN
* (sb-ext:save-lisp-and-die "hello.exe" :toplevel #'main :executable t)
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into hello.exe:
writing 3160 bytes from the read-only space at 0x22000000
writing 2592 bytes from the static space at 0x22100000
writing 30134272 bytes from the dynamic space at 0x22300000
done]
> dir hello.exe
31,457,304 hello.exe
> hello.exe

"hello"

31MB可执行文件

你能提供更多的信息吗?这指向了正确的方向,但是对于一个口齿不清的新手来说,有很多信息需要消化。谢谢,这是安东所说的一个很好的例子。有两个问题,您将如何从现有的lisp文件创建可执行文件,以及是否可以将可执行文件的大小减小?@JamesMcMahon:其他一些CL实现也可以减小大小。例如Clozure CL、CLISP、LispWorks、Allegro CL、MKCL。可以使用商用“mocl”编译器(尽管目前不适用于windows)创建非常小的程序,该编译器只支持Common Lisp的一大子集,不支持运行时代码加载、运行时编译、完整运行时评估等。使用mocl,您可以获得小型应用程序,但是它们是静态的-类似于您从C编译器中所期望的。它实际上编译成C代码。
(defun main ()
    (format t "Hello, world!~%"))

(sb-ext:save-lisp-and-die "hello-world.exe"
:executable t
:toplevel 'main)