PDA

View Full Version : Compiling with SBCL


GnuVince
08-12-2002, 11:59 AM
I have a small program and I would like to compile it with SBCL, what do I need to do?

file13
08-13-2002, 12:37 PM
it's just like CMUCL or any other Lisp:


* (compile-file "test.lisp")
; compiling file "/home/file13/tmp/test.lisp" (written 29 JUL 2002 05:07:39 PM):
; recognizing DEFUN HOWDY
; compiling top level form:
; compiling DEFUN HOWDY:
; compiling top level form:
; compiling top level form:

; /home/file13/tmp/test.fasl written
; compilation finished in 0:00:00

#P"/home/file13/tmp/test.fasl"
NIL
NIL
*


:)

GnuVince
08-14-2002, 09:15 AM
And what do I do with that file to run it?

file13
08-14-2002, 11:42 AM
let's say i have test.lisp that looks like this:


(defun main ()
(format t "Howdy!~%")
(quit))

(main)


to run it without compiling it i would go


[file13@anatta tmp]$ sbcl --noinform --load test.lisp
Howdy!


if you compile it you just change the .lisp to .fasl


[file13@anatta tmp]$ sbcl --noinform --eval '(compile-file "test.lisp")' --eval '(quit)'
; compiling file "/home/file13/tmp/test.lisp" (written 14 AUG 2002 09:29:56 AM):
; recognizing DEFUN MAIN
; compiling top level form:
; compiling DEFUN MAIN:
; compiling top level form:
; compiling top level form:

; /home/file13/tmp/test.fasl written
; compilation finished in 0:00:00
[file13@anatta tmp]$ sbcl --noinform --load test.fasl
Howdy!


for CMUCL on Linux i basically use this:

http://users.actrix.co.nz/mycroft/runlisp.html

i name it rlisp for debugging non-compiled stuff but also i can invoke .x86f files as if they were stand alone executables. you could probably hack with sbcl to get this method to work too. the only thing is watch out because clisp also uses .fasl as the extention. if not just write a shell script to invoke it.

BTW: yes this does mean cmucl and sbcl do NOT produce stand alone executables. they run like Java. gcl and ecls do produce standalone binaries if that's what you're looking for.

hope this helps. :)