I've learned scheme and quickly mastered a lot of it, then did a project in it just fine. Literally took me days to finish. I'm now trying to learn common lisp to get a feel for that and now I'm just really really struggling with trying to learn asdf. It seems to be common knowledge how to use it with libraries but I'm baffled. I guess it's because most lisp programs are made and run inside the repl because that all works fine. It's when I try to compile it to an executable where I'm loosing my place.
Is there anyone who can give me any advice on it or point me to a tutorial for it? I really want to be able to make an executable to give to people without having to explain how to install sbcl and (require) it then run it. I just want to learn to do something substantial in lisp that I haven't been able to do with scheme.
I guess I could use scheme and use ffi to get c libraries to work, but I have no experience with c. I'm just a web developer learning lisp for my own personal reasons. Of course learning some c and ffi may not take as long as this haha.
Thanks

- 39,638
- 28
- 112
- 212

- 1,995
- 2
- 18
- 29
-
I'd like to help you and was writing replies to your questions on comp.lang.lisp. Am I not responding fast enough? – Xach Sep 28 '10 at 22:48
-
No, lol. It felt like I was holding onto you like a life line, I was afraid you may get busy and I'd take up too much of your time. So I posted here to see if anyone else could pitch in that may not be on comp.lang.lisp. – Isaiah Sep 29 '10 at 00:53
2 Answers
I really want to be able to make an executable to give to people without having to explain how to install sbcl and (require) it then run it.
You do not need ASDF in order to produce a 'stand-alone' executable. Most implementations provide means to save an executable image, but how to do this (and if it is to be provided at all) is not mentioned in the standard.
In general, you would load your code into your running image and then "dump" that image.
In SBCL for example, you would use sb-ext:save-lisp-and-die; CCL has ccl:save-application. You will have to look in your implementation's documentation in order to find out how to do it.
I don't have SBCL here at the moment, but this minimal example should work (untested):
(defun do-it () (format t "hello world~%"))
(sb-ext:save-lisp-and-die "hello" :toplevel #'do-it :executable t)
This is a working example using CCL:
Welcome to Clozure Common Lisp Version 1.6-dev-r14287M-trunk (LinuxX8632)!
? (defun do-it () (format t "hello world~%"))
DO-IT
? (ccl:save-application "hello" :toplevel-function #'do-it :prepend-kernel t)
[danlei@susi ~/build/ccl]% ./hello
hello world
These executable images may be of rather big size, unless your implementation provides something like a tree-shaker, but I do not think that this should be a problem nowadays.
You can find a detailed example for clisp in another SO question about this topic.
-
Did that answer your question? I'm not quite sure if I understood correctly, because you said, that everything works from the REPL. If you can load your libs in the REPL, what I described above is the way to get a stand-alone executable, which you then can distribute to your users. If you want them to have the normal REPL, but with your libraries already present in the image, just omit the :toplevel(-function) keyword arguments. – danlei Sep 29 '10 at 01:44