Lisp可执行
时间:2020-03-05 18:42:35 来源:igfitidea点击:
我刚刚开始学习Lisp,我不知道如何编译Lisp代码并将其链接到可执行文件。
我正在使用clisp
和clisp -c
产生两个文件:
- .fas
- .lib
接下来我该怎么做才能获得可执行文件?
解决方案
回答
看看官方的剪辑首页。有一个常见问题解答可以回答这个问题。
http://clisp.cons.org/impnotes/faq.html#faq-exec
回答
我实际上今天正在尝试执行此操作,但发现在CLisp REPL中键入以下内容有效:
(EXT:SAVEINITMEM "executable.exe" :QUIET t :INIT-FUNCTION 'main :EXECUTABLE t :NORC t)
其中main是我们要在程序启动时调用的函数的名称,:QUIET t
禁止显示启动标语,:EXECUTABLE t
构成本机可执行文件。
打电话也很有用
(EXT:EXIT)
在主要功能的末尾,以阻止用户在程序完成后获得交互式Lisp提示。
编辑:阅读文档,我们可能还想添加:NORC t
(阅读链接)。这样可以禁止加载RC文件(例如,〜/ .clisprc.lisp)。
回答
这是一个Lisp常见问题解答(略有改动):
*** How do I make an executable from my programme? This depends on your implementation; you will need to consult your vendor's documentation. With ECL and GCL, the standard compilation process will produce a native executable. With LispWorks, see the Delivery User's Guide section of the documentation. With Allegro Common Lisp, see the Delivery section of the manual. etc... However, the classical way of interacting with Common Lisp programs does not involve standalone executables. Let's consider this during two phases of the development process: programming and delivery. Programming phase: Common Lisp development has more of an incremental feel than is common in batch-oriented languages, where an edit-compile-link cycle is common. A CL developer will run simple tests and transient interactions with the environment at the REPL (or Read-Eval-Print-Loop, also known as the listener). Source code is saved in files, and the build/load dependencies between source files are recorded in a system-description facility such as ASDF (which plays a similar role to make in edit-compile-link systems). The system-description facility provides commands for building a system (and only recompiling files whose dependencies have changed since the last build), and for loading a system into memory. Most Common Lisp implementations also provide a "save-world" mechanism that makes it possible to save a snapshot of the current lisp image, in a form which can later be restarted. A Common Lisp environment generally consists of a relatively small executable runtime, and a larger image file that contains the state of the lisp world. A common use of this facility is to dump a customized image containing all the build tools and libraries that are used on a given project, in order to reduce startup time. For instance, this facility is available under the name EXT:SAVE-LISP in CMUCL, SB-EXT:SAVE-LISP-AND-DIE in SBCL, EXT:SAVEINITMEM in CLISP, and CCL:SAVE-APPLICATION in OpenMCL. Most of these implementations can prepend the runtime to the image, thereby making it executable. Application delivery: rather than generating a single executable file for an application, Lisp developers generally save an image containing their application, and deliver it to clients together with the runtime and possibly a shell-script wrapper that invokes the runtime with the application image. On Windows platforms this can be hidden from the user by using a click-o-matic InstallShield type tool.
回答
CLiki也有一个很好的答案:创建可执行文件