Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling Common Lisp to an executable

I recently started learning Common Lisp using SBCL. How can I compile my Lisp programs into a Windows binary?

like image 331
Shenal Silva Avatar asked Jan 05 '13 12:01

Shenal Silva


People also ask

What does Common Lisp compile to?

Traditionally, LISP can be interpreted or compiled -- with some of each running at the same time. Compilation, in some cases, would be to a virtual machine like JAVA. LISP is a general purpose programming language, but rarely used as such anymore.

Can you compile Lisp?

Most Lisp systems allow you to fully compile code. The compilation step includes the macro expansion phase. There is no expansion needed at runtime. Often Lisp systems include a compiler, but this is needed when code is generated at runtime and this code would need to be compiled.

Is Sbcl compiled?

For what I saw, SBCL doesn't compile to executable and even there are plugins to do that they do not include the dependencies or they package a lot of garbage making heavy executables. I saw that other implementations of Common Lisp actually compile to executables to perform their work.

How do I run a Lisp program in terminal?

Step 1: After logging into a CUIT machine, enter "lisp" after the $ shell prompt and then hit <return>. Another way is to run lisp via emacs: Meta-x run-lisp (i.e. hit 'esc' followed by 'x', type "run-lisp" and you'll be in lisp mode from which you can load files of lisp code...)


1 Answers

Making hello.exe:

* (defun main () (print "hello"))  MAIN * (sb-ext:save-lisp-and-die "hello.exe" :toplevel #'main :executable t) [undoing binding stack and other enclosing state... done] [saving current Lisp image into hello.exe: writing 3160 bytes from the read-only space at 0x22000000 writing 2592 bytes from the static space at 0x22100000 writing 30134272 bytes from the dynamic space at 0x22300000 done] > dir hello.exe 31,457,304 hello.exe > hello.exe  "hello" 

31 MB executable file!

like image 182
KIM Taegyoon Avatar answered Sep 23 '22 16:09

KIM Taegyoon