I recently started learning Common Lisp using SBCL. How can I compile my Lisp programs into a Windows binary?
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.
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.
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.
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...)
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With