2008-08-24 11 views
57

Acabo de empezar a aprender Lisp y no puedo encontrar la manera de compilar y vincular el código de lisp a un ejecutable.Lisp Ejecutable

estoy usando clisp y clisp -c produce dos archivos:

  • .fas
  • .lib

¿Qué hago siguiente para conseguir un ejecutable?

+0

En su lugar, podría usar 'compile-file'. –

Respuesta

47

que estaba tratando de hacer esto hoy, y me encontré escribiendo esto en el CLISP REPL trabajó:

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

donde principal es el nombre de la función que desea llamar cuando el el programa se inicia, :QUIET t suprime el banner de inicio y :EXECUTABLE t lo convierte en un ejecutable nativo.

También puede ser útil para llamar

(EXT:EXIT) 

al final de su función principal con el fin de detener el usuario consiga un símbolo Lisp interactivo cuando el programa se lleva a cabo.

EDIT: leyendo la documentación, es posible que también desee agregar :NORC t (lea link). Esto suprime la carga del archivo RC (por ejemplo, ~/.clisprc.lisp).

+0

En ccl en mac os x 10.9 estoy teniendo problemas para crear ejecutables. '(save-application"/full/path/to/saved-app ": prepend-kernel t)' haciendo doble clic en el archivo ejecutable producido ingresa en el terminal mostrando errores muy largos comenzando con un error similar: problemas al cargar el paquete: no puede determinar el nombre de la clase y termina con las opciones del depurador del kernel. En ccl en windows simplemente defino una función y hago lo mismo arriba para guardar ejecutable, luego puedo hacer doble clic en el archivo de salida que ejecuta y recordar mi función definida, ccl en mac no recuerdo también cuando guardo la imagen y la cargo al kernel manualmente –

35

Ésta es una Lisp FAQ (ligeramente adaptado):

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

Para una manera portátil para hacer esto, recomiendo roswell.

Para cualquier implementación compatible puede crear scripts de lisp para ejecutar el programa que se puede ejecutar de forma portátil por ros que se puede utilizar en una línea de hash-bang de forma similar a un programa python o ruby.

Para SBCL y CCL roswell también puede crear ejecutables binarios con ros dump executable.

+0

¿Por qué se bajó este voto? – Thayne

0

;; Sé que esto es una cuestión de edad, pero el código Lisp estoy mirando tiene 25 años :-)

no pude conseguir la compilación trabajar con clisp en Windows 10. Sin embargo, a mí me funcionó con GCL

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

;; mi archivo lisp es jars2.lisp

gcl -compile jugs2.lisp ;; esto produce el archivo jars2.o si jugs2.el archivo lisp no tiene errores

;; ejecutar gcl sin parámetros para iniciar el intérprete de lisp gcl

;; cargar el archivo .o

(load "jugs2.o")

;; crear un exe

(si:save-system "jugs2")

;; cuando se ejecuta el exe, necesita el dll encrpc.dll ;; esto está en la carpeta \ lib \ gcl-2.6.1 \ unixport que crea gcl.bat.

;; cuando se ejecuta muestra un entorno de lisp, llamada (principal) para ejecutar la función principal (principal)