2008-08-24 72 views
57

我剛開始學習Lisp和我想不出如何編譯和Lisp代碼鏈接到一個可執行文件。Lisp的可執行

我使用clispclisp -c產生兩個文件:

  • .fas
  • 的.lib

我該怎麼辦旁邊得到一個可執行文件?

+0

你可以使用`編譯file`代替。 – 2016-07-17 03:05:39

回答

47

實際上,我是想這樣做今天,我發現打字這個到CLISP REPL工作:

(EXT:SAVEINITMEM "executable.exe" 
       :QUIET t 
       :INIT-FUNCTION 'main 
       :EXECUTABLE t 
       :NORC t) 

,其中主要是你想打電話時,該功能的名稱程序啓動,:QUIET t抑制啓動旗幟,:EXECUTABLE t,使本機的可執行文件。

它也可以調用

(EXT:EXIT) 

在你的主函數的末尾,以便從程序完成後得到一個互動的口齒不清提示停止對用戶有用的。

編輯:閱讀文檔,您可能還需要添加:NORC t (閱讀link)。這會禁止加載RC文件(例如,~/.clisprc.lisp)。

+0

在mac os上的ccl x 10.9我有一個創建可執行文件的問題。 `(保存的應用程序「/全/路徑/到/保存的應用內」:前置內核噸)` 雙擊產生可執行文件上輸入端子示出開始與一個像錯誤很長的錯誤:問題loadiing束:無法確定類名並以內核調試器選項結束。在Windows上CCL我簡單地定義一個函數,做同樣的上述保存可執行文件,以後我可以雙擊它運行,並記得在Mac我定義的功能,CCL也不記得當我保存圖像的輸出文件並加載它手動內核 – 2014-01-06 00:53:15

35

這是一個Lisp FAQ(稍作改動):

*** 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.

3

的便攜式辦法做到這一點,我建議roswell

對於任何受支持的實現,您可以創建lisp腳本來運行程序,該程序可以通過ros以便攜方式運行,可以在類似於python或ruby程序的散列行中使用。

對於SBCL與CCL羅斯威爾還可以創建二進制可執行文件與ros dump executable

+0

爲什麼這是低調的? – Thayne 2016-03-15 22:57:49

0

;;我知道這是一個老問題,但我看Lisp代碼是25歲:-)

我不能讓編譯與CLISP在Windows 10 工作然而,它爲我工作與保利協鑫

https://www.cs.utexas.edu/users/novak/gclwin.html

;;;我口齒不清文件jugs2.lisp

GCL -compile jugs2.lisp ;;這會產生文件jugs2.o if jugs2。LISP文件沒有錯誤

;;不帶參數運行GCL推出Lisp解釋 GCL

;;加載.o文件

(load "jugs2.o")

;;創建一個exe文件

(si:save-system "jugs2")

;;當exe運行時,需要使用dll oncrpc.dll ;;這是在gcl.bat創建的\ lib \ gcl-2.6.1 \ unixport文件夾中。

;;運行時,它顯示了一個口齒不清的環境,請致電(主)運行的主要功能 (主)