Compiling to binary
Compiling to binary
Hi,
When using Windows, is it possible to compile my lisp programs into binaries so i could run the outside the 'lispbox'?
When using Windows, is it possible to compile my lisp programs into binaries so i could run the outside the 'lispbox'?
Re: Compiling to binary
With commercial implementations, yes. With open source implementation usually also yes, although it can be more problematic. I am not familiar with Common Lisps/Lispbox on Windows, but perhaps something on the creating executables CLiki page is applicable.
Re: Compiling to binary
Which lispbox did you download? What are (lisp-implementation-type) and (lisp-implementation-version)?
Re: Compiling to binary
I do not know about 'lispbox', but ECL (http://ecls.sourceforge.net) can build standalone programs using Microsoft Visual C++ It may be a little bit more complicated to set up than other lisps (help is welcome in creating standalone environments) because it requires building ECL from sources, but it may be worth looking at it.kapalua wrote:Hi,
When using Windows, is it possible to compile my lisp programs into binaries so i could run the outside the 'lispbox'?
Re: Compiling to binary
(lisp-implementation-type) = "CLISP"
(lisp-implementation-version) = "2.33 (2004-03-17) (built on winsteingoldlap [10.0.19.22])"
What i mean by 'lispbox' is 'lisp-in-a-box' running on XP. Also refered to as SLIME i belivie.
I get a feeling that compiling into binaries are not very common using lisp; is it usually just runned from inside the repl? What about the output the (compile-file) command creates, what can i do with that?
(lisp-implementation-version) = "2.33 (2004-03-17) (built on winsteingoldlap [10.0.19.22])"
What i mean by 'lispbox' is 'lisp-in-a-box' running on XP. Also refered to as SLIME i belivie.
I get a feeling that compiling into binaries are not very common using lisp; is it usually just runned from inside the repl? What about the output the (compile-file) command creates, what can i do with that?
Re: Compiling to binary
COMPILE-FILE creates a so called FASL file, which is short for 'FASt Load', which allows loading precompiled code into an image. Those are usually not independently executable, since they depend on the Lisp runtime.kapalua wrote:I get a feeling that compiling into binaries are not very common using lisp; is it usually just runned from inside the repl? What about the output the (compile-file) command creates, what can i do with that?
Common Lisp is an image based language. To obtain an independent executable you can save a copy of an image with all your code and data loaded and give it a function to run on startup. On CLISP this is done using a SAVEINITMEM function. Do note that the resulting file will be relatively large (although CLISP generates quite small images compared to other Lisps), since it contains an entire Lisp environment. There are only a few Lisp systems which separate the runtime system from the program, with ECL being the most popular open source one.
Re: Compiling to binary
Ok, thank you for clarifying.
From this, my conclusion is that the lisp programs most of the time are runned from inside the lisp enviroment/repl and that if i don't have any very specific reason to create a standalone executable it's not worth doing/no need.
I guess i just have to start coding away.
From this, my conclusion is that the lisp programs most of the time are runned from inside the lisp enviroment/repl and that if i don't have any very specific reason to create a standalone executable it's not worth doing/no need.
I guess i just have to start coding away.

Re: Compiling to binary
Many implementations have their own way to generate "executables". More commonly, people just write shell scripts (or batch files) that load a "main" file. The usage looks something like clisp --norc -i main.lisp (from foggy memory). On unix, cl-launch can help automate the process.
Re: Compiling to binary
This is exactly correct: think of it as being like a JVM that you can interact with while it's running.kapalua wrote:From this, my conclusion is that the lisp programs most of the time are runned from inside the lisp enviroment/repl and that if i don't have any very specific reason to create a standalone executable it's not worth doing/no need.
If you really need something that you can run from the command-line or by double-clicking on an icon, that can be done in one of two ways with SBCL. You can create a command-line script that will pass it run-time arguments that tell it to load a package, run a command, etc. - I use this to automatically start up server processes. You can also use the save-lisp-and-die command to dump an image to disk; this can include the lisp VM, which makes it a self-contained executable; it also makes for a large file.
SLIME is a system that allows Emacs to talk to the running Lisp image; it's part of lisp-in-a-box, but the other parts are the Lisp VM/compiler/interpreter and Emacs, probably along with some useful packages. I'm guessing about the packages because I haven't actually used lisp-in-a-box - I can't stand Emacs, so I just use VILisp and SBCL.
-
- Posts: 406
- Joined: Sat Mar 07, 2009 6:17 pm
- Location: Brazil
- Contact:
Re: Compiling to binary
SBCL has also the sb-executable extension. It has a function named make-executable which receives a list of pathnames of fasls (and a initial function) and creates an executable script containing those files.