Lisp executable

I was just starting to learn Lisp, and I can't figure out how to compile and link Lisp code to an executable.

I use clisp and clisp -c creates two files:

  • .fas
  • .lib

What should I do to get an executable file?

+57
build lisp common-lisp clisp
Aug 24 '08 at 13:42
source share
6 answers

I really tried to do this today, and I found that I typed this in the CLisp REPL:

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

where main is the name of the function that you want to call when the program starts :QUIET t suppresses the launch banner, and :EXECUTABLE t creates its own executable file.

Also useful to call

 (EXT:EXIT) 

at the end of your main function so that the user does not receive an interactive lisp prompt when the program is executed.

EDIT: after reading the documentation, you can also add :NORC t (read the link ). This suppresses the loading of the RC file (e.g. ~/.clisprc.lisp ).

+47
Aug 24 '08 at 23:10
source share

This is the Lisp FAQ (slightly adapted):

*** How to create an executable file from my program?

It depends on your implementation; You will need to consult the supplier documentation.

  • With ECL and GCL, the standard compilation process will create your own executable.

  • In 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 classic way to interact with Common Lisp programs does not include stand-alone executables. Consider this during the two stages of the development process: programming and delivery.

Programming Stage: General development of Lisp is more than usual in package-oriented languages, where the editing-compilation cycle is general. The CL developer will run simple testing and transient environmental interactions on the REPL (or Read-Eval-Print-Loop, also known as the listener). The source code is saved in files, and the build / load dependencies between the source files are recorded in a system description such as ASDF (which plays a similar role in editing-compilation systems). The system description tool provides commands for creating the system (and only recompiling files, dependencies have changed since the last build), as well as for loading the system into memory.

The most common Lisp implementations also provide a "save the world" mechanism that allows you to save a snapshot of the current Lisp image in a form that can later be restarted. A general Lisp environment usually consists of a relatively small runtime and a larger image file containing the state of the Lisp world. A common use of this tool is to reset a customized image containing everything to create tools and libraries that are used in this project, in order to reduce startup time. For example, this object is available in 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 deliver the runtime image, thereby making it executable.

Application delivery: instead of generating a single executable file for the application, Lisp developers usually save the image containing their application and deliver it to clients along with the runtime and, possibly, a shell script that calls the runtime with the application image. On Windows platforms, this can be hidden from the user using a tool like InstallShield click-o-matic.

+35
Aug 27 '08 at 23:40
source share

Take a look at the official homepage. This question is answered by the FAQ.

http://clisp.cons.org/impnotes/faq.html#faq-exec

+14
Aug 24 '08 at 13:55
source share

CLiki also has a good answer: Creating executable files

+13
Jun 25 '09 at 17:32
source share

For a portable way to do this, I recommend roswell .

For any supported implementation, you can create lisp scripts to run a program that can be run in a portable way using ros , which can be used in a hash string, similar to python or ruby.

For SBCL and CCL, roswell can also create binary executables with ros dump executable .

+3
Dec 10 '15 at 6:36
source share

;; I know this is an old question, but the Lisp code I'm looking at is 25 years old :-)

I could not get compilation to work with clisp on Windows 10. However, this worked for me with gcl

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

;; my Lisp file jugs2.lisp

gcl -compile jugs2.lisp ;; this creates a jugs2.o file if the jugs2.lisp file has no errors

;; run gcl without parameters to start the Lisp GCL interpreter

;; download the .o file

(load "jugs2.o")

;; create exe

(si: save-system "jugs2")

;; when exe starts, it needs dll oncrpc.dll ;; this is located in the \ lib \ gcl-2.6.1 \ unixport folder created by gcl.bat.

;; when launched, it shows the Lisp environment, a call (main) to launch the main function (main)

0
Aug 26 '17 at 2:02 on
source share



All Articles