The lisp program to compile :

library.lisp

(load "~/quicklisp/setup.lisp")
(declaim (optimize (speed 3) (safety 3) (space 0) (debug 3)))
(ql:quickload "defstar")

(defpackage package-library
    (:use #:cl #:defstar)
    (:export printstring))

(in-package :package-library)
(defun* (printstring -> boolean) ((s string))
    (princ s) t)

The lisp program performing the compilation :

compîle.lisp

(declaim (optimize (speed 3) (safety 3) (space 0) (debug 3)))
(load "~/quicklisp/setup.lisp")

(format t "~a~%" "COMPILING library.lisp")
(CL:COMPILE-FILE "library.lisp")

(format t "~a~%" "Done compiling")
(quit)

The script to perform the compilation :

rm *.abcl
echo "COMPILING"
time abcl --noinform --noinit --nosystem --load compile.lisp

The error/bug :


COMPILING library.lisp
; Compiling /mnt/xxx_data/Languages_ok/lisp/abcl/module/library.lisp ...
; (LOAD "~/quicklisp/setup.lisp")
; (DECLAIM (OPTIMIZE # ...))
; (QUICKLISP-CLIENT:QUICKLOAD "defstar")
; (DEFPACKAGE PACKAGE-LIBRARY ...)
Error loading /mnt/xxx_data/Languages_ok/lisp/abcl/module/compile.lisp at line 6 (offset 171)
#: Debugger invoked on condition of type ERROR
  DEFSTAR is not the name of a package.

  • Ok_Specific_7749@alien.topOPB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Thanks for answering/solving this problem. It was not obvious for me.
    Now i have another question would it be possible to do something similar using sbcl or ccl. I.e. creating a compiled library and calling it from a main.lisp file.

  • lispm@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    You compile the file compile.lisp. You don’t load it, you are compiling it.

    That means: you compile the expression (ql:quickload "defstar"), but you don’t execute it. The file-compiler generates code for function calls, but does not execute them.

    Then the package stuff does not know the package named “DEFSTAR”, because the thing has not been loaded.

    See EVAL-WHEN:

    (eval-when (:compile-toplevel :load-toplevel :execute)
      (ql:quickload "defstar"))
    

    Above makes sure that the enclosed form is also executed during compilation.