Given a simple program such as the following, how would you:
-
compile it as a seperate image file to be loaded by the implementation, and what command line arguments would you use to load it?
-
Compile it as a standalone binary that can be loaded and run as is.
Note: I tried adding “:prepend-kernel t” when saving the application only to have the follow error thrown.
Error: value NIL is not of the expected type REAL. While executing: CCL::<-2, in process Initial(0). -
How would you supress the welcome message?
The Program
(defun main () (format t "This is the program.")0)
Edit
Hate to answer part of my own question, but I found it none the less.
After the function has been loaded type the following to compile it:
(ccl:save-application "app")
This creates an image file. To load it by passing it to the implementation type (note: the ‘ccl’ binary is in my system path);
ccl -I app
To run a top level function pass it as a parameter
ccl -I app --eval (main)
See the Clozure Common Lisp documentation under Saving Applications
Compiling and Loading Lisp files
You can compile a file named
/foo/bar.lispby callingThis will create a fasl (FASt Load) file, which contains native code.
You can load the compiled file, the fasl file, with the function
LOAD.LOADandCOMPILE-FILEare standard Common Lisp functions.Creating applications
A few definitions:
You can save an application by calling a CCL specific function:
This will save an image, that you can run using the CCL kernel from a command shell:
To save an executable that includes the kernel use this from Lisp:
You can call this executable as usual with
/foo/bar-appfrom a command shell.In Clozure Common Lisp you can check
for the list of provided command line arguments.