Re: compiling a Lisp source to exe
- From: pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
- Date: Tue, 30 Sep 2008 00:50:59 +0200
Pascal Costanza <pc@xxxxxxxxx> writes:
cartercc wrote:
I looked at LispWorks now, and almost fell out of my chair at the
prices. I am a student and frankly cannot afford this product. Does
the Personal Edition create exe files? The blurb says that it does not
support application delivery?
If you are a student and don't want to sell software products for a
living, you don't need to create exe files. Lisp programs are
traditionally deployed differently, except for shrink-wrapped
software.
Sometimes teachers allow any programming languages for the project, as
long as the students can deliver an executable with the sources.
cartercc, it will be difficult (but possible) to build a command line
to generate an executable from a source file with most lisp
implementations. What you should do, is to build the executable, from
the source file, not from the command line.
In addition to your your-source.lisp, have a loader.lisp containing:
-----(loader.lisp)------------------------------------------------------
(defun save-executable-image (name &key init-function
(start-package (find-package "COMMON-LISP-USER"))
(documentation (documentation init-function 'function)))
#+clisp (ext:saveinitmem
name
:executable t
:quiet t :norc t
:init-function (if init-function
(lambda () (funcall init-function ext:*args*) (ext:exit 0))
(lambda ()))
:documentation documentation
:start-package start-package)
#+sbcl (sb-ext:save-lisp-and-die
name
:executable t
:toplevel (lambda ()
(setf *package* start-package)
(setf sb-int:*repl-prompt-fun* (function prompt))
(if init-function
(funcall init-function (rest SB-EXT:*POSIX-ARGV*))
(sb-impl::toplevel-repl nil))
(sb-ext:quit :unix-status 0)))
#-(or clisp sbcl) (error "How do we save an image in ~A"
(lisp-implementation-type)))
(load (compile-file "your-source.lisp")) ; and any other dependencies
(save-executable-image "MyProgram" (function your-package:your-main-function))
------------------------------------------------------------------------
And then you can run this loader.lisp script from the command line to
have it load your sources, compile them and save an executable.
You can execute Lisp programs directly from within a Lisp
environment. This includes compiling programs to low-level machine
code and executing that, which makes this competitive with other
compiled languages.
This is of course the recommanded "lisp way of life".
It takes a while to get used to that somewhat different interaction
with a language environment, but it has strong benefits over the
edit-compile-link-run cycle. Take some time to learn this, and you'll
see.
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
--
__Pascal Bourguignon__ http://www.informatimago.com/
Nobody can fix the economy. Nobody can be trusted with their finger
on the button. Nobody's perfect. VOTE FOR NOBODY.
.
- References:
- compiling a Lisp source to exe
- From: cartercc
- Re: compiling a Lisp source to exe
- From: Rainer Joswig
- Re: compiling a Lisp source to exe
- From: cartercc
- Re: compiling a Lisp source to exe
- From: Pascal Costanza
- compiling a Lisp source to exe
- Prev by Date: Re: RFC 1037 NFILE implementations around?
- Next by Date: Re: where is the lisp operating system?
- Previous by thread: Re: compiling a Lisp source to exe
- Next by thread: Re: compiling a Lisp source to exe
- Index(es):