how does one compile a clisp program which uses cl-ppcre? - lisp

On Debian, I am trying to compile a CLISP program which uses the cl-ppcre package.
A sample, simplified program (which I will call variant 1) looks like this:
(asdf:load-system :cl-ppcre)
(princ (cl-ppcre:regex-replace-all "a" "abcde" "x"))
(terpri)
When I ran it thus::
clisp -q a3.lisp
I got this:
home:~/clisp/ercpp/compiling-program$ clisp -q a3.lisp
; Loading system definition from /usr/share/common-lisp/systems/cl-ppcre.asd into #<PACKAGE ASDF0>
; Registering #<SYSTEM :CL-PPCRE> as CL-PPCRE
; Registering #<SYSTEM :CL-PPCRE-TEST> as CL-PPCRE-TEST
0 errors, 0 warnings
xbcde
home:~/clisp/ercpp/compiling-program$
But when I tried to compile it thus:
clisp -q -c a3.lisp
I got this:
home:~/clisp/ercpp/compiling-program$ clisp -q -c a3.lisp
;; Compiling file /u/home/clisp/ercpp/compiling-program/a3.lisp ...
*** - READ from
#<INPUT BUFFERED FILE-STREAM CHARACTER
#P"/u/home/clisp/ercpp/compiling-program/a3.lisp" #3>
: there is no package with name "CL-PPCRE"
0 errors, 0 warnings
home:~/clisp/ercpp/compiling-program$
I got similar results with successful run and unsuccessful compile with variant 2:
(clc:clc-require :cl-ppcre)
(princ (cl-ppcre:regex-replace-all "a" "abcde" "x"))
(terpri)
What do I need to do to get it to compile?
In case it might help come up with an answer, I looked at the file I/O triggered by running variant 1. I used strace, and sliced and diced the output to show only names of relevant files and directories. When I did this:
strace -o strace.1 clisp -q a3.lisp
grep pcre strace.1 \
| sed -e 's/^[^"]*"//' \
| sed -e 's/".*$//' \
| sort \
| uniq \
> strace.2
I got this output:
(asdf:load-system :cl-ppcre)\n\n(p
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/api.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/charmap.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/charset.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/chartest.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/closures.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/convert.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/errors.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/lexer.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/optimize.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/packages.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/parser.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/regex-class-util.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/regex-class.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/repetition-closures.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/scanner.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/specials.fas
/u/home/.cache/common-lisp/clisp-2.48-unix-x86/usr/share/common-lisp/source/cl-ppcre/util.fas
/u/home/clisp/ercpp/compiling-program/cl-ppcre-test.asd
/usr/share/common-lisp/source/aima/cl-ppcre-test.asd
/usr/share/common-lisp/source/alexandria/cl-ppcre-test.asd
/usr/share/common-lisp/source/arnesi/cl-ppcre-test.asd
/usr/share/common-lisp/source/arnesi/src/cl-ppcre-extras.lisp
/usr/share/common-lisp/source/aspectl/cl-ppcre-test.asd
/usr/share/common-lisp/source/babel/cl-ppcre-test.asd
/usr/share/common-lisp/source/binary-types/cl-ppcre-test.asd
/usr/share/common-lisp/source/blowfish/cl-ppcre-test.asd
/usr/share/common-lisp/source/cedilla/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-acl-compat/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-asdf/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-cffi/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-fad/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-interpol/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-jpeg/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-launch/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-menusystem/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-pdf/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-photo/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-plplot/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-port/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-ppcre
/usr/share/common-lisp/source/cl-ppcre/.
/usr/share/common-lisp/source/cl-ppcre/api.fas
/usr/share/common-lisp/source/cl-ppcre/api.lisp
/usr/share/common-lisp/source/cl-ppcre/charmap.fas
/usr/share/common-lisp/source/cl-ppcre/charmap.lisp
/usr/share/common-lisp/source/cl-ppcre/charset.fas
/usr/share/common-lisp/source/cl-ppcre/charset.lisp
/usr/share/common-lisp/source/cl-ppcre/chartest.fas
/usr/share/common-lisp/source/cl-ppcre/chartest.lisp
/usr/share/common-lisp/source/cl-ppcre/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-ppcre/cl-ppcre-unicode.asd
/usr/share/common-lisp/source/cl-ppcre/cl-ppcre.asd
/usr/share/common-lisp/source/cl-ppcre/closures.fas
/usr/share/common-lisp/source/cl-ppcre/closures.lisp
/usr/share/common-lisp/source/cl-ppcre/convert.fas
/usr/share/common-lisp/source/cl-ppcre/convert.lisp
/usr/share/common-lisp/source/cl-ppcre/errors.fas
/usr/share/common-lisp/source/cl-ppcre/errors.lisp
/usr/share/common-lisp/source/cl-ppcre/lexer.fas
/usr/share/common-lisp/source/cl-ppcre/lexer.lisp
/usr/share/common-lisp/source/cl-ppcre/optimize.fas
/usr/share/common-lisp/source/cl-ppcre/optimize.lisp
/usr/share/common-lisp/source/cl-ppcre/packages.fas
/usr/share/common-lisp/source/cl-ppcre/packages.lisp
/usr/share/common-lisp/source/cl-ppcre/parser.fas
/usr/share/common-lisp/source/cl-ppcre/parser.lisp
/usr/share/common-lisp/source/cl-ppcre/regex-class-util.fas
/usr/share/common-lisp/source/cl-ppcre/regex-class-util.lisp
/usr/share/common-lisp/source/cl-ppcre/regex-class.fas
/usr/share/common-lisp/source/cl-ppcre/regex-class.lisp
/usr/share/common-lisp/source/cl-ppcre/repetition-closures.fas
/usr/share/common-lisp/source/cl-ppcre/repetition-closures.lisp
/usr/share/common-lisp/source/cl-ppcre/scanner.fas
/usr/share/common-lisp/source/cl-ppcre/scanner.lisp
/usr/share/common-lisp/source/cl-ppcre/specials.fas
/usr/share/common-lisp/source/cl-ppcre/specials.lisp
/usr/share/common-lisp/source/cl-ppcre/util.fas
/usr/share/common-lisp/source/cl-ppcre/util.lisp
/usr/share/common-lisp/source/cl-salza/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-split-sequence/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-statistics/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-utilities/cl-ppcre-test.asd
/usr/share/common-lisp/source/cl-who/cl-ppcre-test.asd
/usr/share/common-lisp/source/closer-mop/cl-ppcre-test.asd
/usr/share/common-lisp/source/contextl/cl-ppcre-test.asd
/usr/share/common-lisp/source/csv/cl-ppcre-test.asd
/usr/share/common-lisp/source/fiveam/cl-ppcre-test.asd
/usr/share/common-lisp/source/ftp/cl-ppcre-test.asd
/usr/share/common-lisp/source/getopt/cl-ppcre-test.asd
/usr/share/common-lisp/source/infix/cl-ppcre-test.asd
/usr/share/common-lisp/source/inflate/cl-ppcre-test.asd
/usr/share/common-lisp/source/ironclad/cl-ppcre-test.asd
/usr/share/common-lisp/source/iterate/cl-ppcre-test.asd
/usr/share/common-lisp/source/kmrcl-tests/cl-ppcre-test.asd
/usr/share/common-lisp/source/kmrcl/cl-ppcre-test.asd
/usr/share/common-lisp/source/lexer/cl-ppcre-test.asd
/usr/share/common-lisp/source/lw-compat/cl-ppcre-test.asd
/usr/share/common-lisp/source/md5/cl-ppcre-test.asd
/usr/share/common-lisp/source/metering/cl-ppcre-test.asd
/usr/share/common-lisp/source/net-telent-date/cl-ppcre-test.asd
/usr/share/common-lisp/source/onlisp/cl-ppcre-test.asd
/usr/share/common-lisp/source/pipes/cl-ppcre-test.asd
/usr/share/common-lisp/source/png/cl-ppcre-test.asd
/usr/share/common-lisp/source/ptester/cl-ppcre-test.asd
/usr/share/common-lisp/source/puri/cl-ppcre-test.asd
/usr/share/common-lisp/source/qbook/cl-ppcre-test.asd
/usr/share/common-lisp/source/readline/cl-ppcre-test.asd
/usr/share/common-lisp/source/regex/cl-ppcre-test.asd
/usr/share/common-lisp/source/reversi/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-bitcomp/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-bool-comp/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-cache/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-delayed/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-filter/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-fuzzy/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-mod/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-modal/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-queue/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-rand/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-random/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-rsa/cl-ppcre-test.asd
/usr/share/common-lisp/source/rsm-string/cl-ppcre-test.asd
/usr/share/common-lisp/source/rt/cl-ppcre-test.asd
/usr/share/common-lisp/source/series/cl-ppcre-test.asd
/usr/share/common-lisp/source/slime/cl-ppcre-test.asd
/usr/share/common-lisp/source/trivial-features/cl-ppcre-test.asd
/usr/share/common-lisp/source/uffi-tests/cl-ppcre-test.asd
/usr/share/common-lisp/source/uffi/cl-ppcre-test.asd
/usr/share/common-lisp/source/units/cl-ppcre-test.asd
/usr/share/common-lisp/source/url-rewrite/cl-ppcre-test.asd
/usr/share/common-lisp/source/usocket/cl-ppcre-test.asd
/usr/share/common-lisp/source/usocket/test/cl-ppcre-test.asd
/usr/share/common-lisp/source/yacc/cl-ppcre-test.asd
/usr/share/common-lisp/source/yaclml/cl-ppcre-test.asd
/usr/share/common-lisp/systems/cl-ppcre-test.asd
/usr/share/common-lisp/systems/cl-ppcre.asd
So what do I do?

If you compile some file which uses a package like (cl-ppcre:bar ...) then you need make sure that the package exists.
Compiling a statement like (asdf:load-system :cl-ppcre) does not cause loading the system at compile-time. Thus the package definition is also not loaded and executed. The compiler generates code for this statement, so that it only executes at load-time.
Either you load the system some way before you compile the file or you use
(eval-when (:compile-toplevel :load-toplevel :execute)
(asdf:load-system :cl-ppcre))
in the file to make sure that it is loaded into the compile-time environment.

Related

Join two lists of strings in a makefile

In my makefile there is a variable that contains all source files:
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
I now want to create a DEPFILES that contains the same files as SOURCES with two main differences:
Each file ends with ".d" instead of ".c"
Each file contains a "." before its basename, such that the resulting file is hidden.
I came up with this expression, which works well:
DEPFILES := $(foreach s,$(SOURCES:.$(SRCEXT)=.$(DEPSEXT)),$(shell echo $(s) | sed -e 's/^\(.*\/\)/\1./')))
Initially, I split SOURCES into the following lists:
PRE := $(dir $(SOURCES))
SUF := $(addprefix ".", $(notdir $(SOURCES)))
Question: How do you join those two lists in a makefile, such that the results equals DEPFILES? In other words: How do you pairwisely concat the strings from both lists?
Here is a simpler approach using makefile only and no shell - if I understood your requirement ok:
SRCS += bob/src1.c fred/src2.c src3.c
DEPS=$(join $(addsuffix ., $(dir $(SRCS))), $(notdir $(SRCS:.c=.d)))
# Some debug:
$(info 1. $(SRCS))
$(info 2. $(SRCS:.c=.d))
$(info 3. $(notdir $(SRCS:.c=.d)))
$(info 4. $(dir $(SRCS)))
.PHONY: all
all:
#echo SRCS: $(SRCS)
#echo DEPS: $(DEPS)
I broke the output down into steps so you can see what each part does - saves me to explain it!
outputs:
1. bob/src1.c fred/src2.c src3.c
2. bob/src1.d fred/src2.d src3.d
3. src1.d src2.d src3.d
4. bob/ fred/ ./
SRCS: bob/src1.c fred/src2.c src3.c
DEPS: bob/.src1.d fred/.src2.d ./.src3.d

swiftc: Possible values for "-target" command line option

There is Swift compiler option -target:
$ swiftc -h
...
-target <value> Generate code for the given target
...
Where from can I get all possible values for compiler option -target (i.e: x86_64-apple-ios11.0, x86_64-apple-macosx10.12, ...) ?
Thanks!
Look at https://github.com/apple/swift/blob/master/utils/build-script-impl
Search the build script for terms like SWIFT_HOST_VARIANT, SWIFT_HOST_VARIANT_SDK, SWIFT_HOST_VARIANT_ARCH and SWIFT_HOST_TRIPLE
#!/usr/bin/env bash
#===--- build-script-impl - Implementation details of build-script ---------===#
#
## This source file is part of the Swift.org open source project
# Each variable name is re-exported into this script in uppercase, where dashes
# are substituted by underscores. For example, `swift-install-components` is
# referred to as `SWIFT_INSTALL_COMPONENTS` in the remainder of this script.
KNOWN_SETTINGS=(
# name default description
# ... snip ...
darwin-deployment-version-osx "10.9" "minimum deployment target version for OS X"
darwin-deployment-version-ios "7.0" "minimum deployment target version for iOS"
# ... snip ...
function set_build_options_for_host() {
llvm_cmake_options=()
swift_cmake_options=()
cmark_cmake_options=()
lldb_cmake_options=()
swiftpm_bootstrap_options=()
SWIFT_HOST_VARIANT=
SWIFT_HOST_VARIANT_SDK=
SWIFT_HOST_VARIANT_ARCH=
SWIFT_HOST_TRIPLE=
local host="$1"
# Hosts which can be cross-compiled must specify:
# SWIFT_HOST_TRIPLE and llvm_target_arch (as well as usual HOST_VARIANT flags)
case ${host} in
freebsd-x86_64)
SWIFT_HOST_VARIANT="freebsd"
SWIFT_HOST_VARIANT_SDK="FREEBSD"
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
cygwin-x86_64)
SWIFT_HOST_VARIANT="cygwin"
SWIFT_HOST_VARIANT_SDK="CYGWIN"
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
# ... snip ...
linux-*)
SWIFT_HOST_VARIANT="linux"
SWIFT_HOST_VARIANT_SDK="LINUX"
case ${host} in
linux-x86_64)
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
# ... snip ...
linux-aarch64)
SWIFT_HOST_VARIANT_ARCH="aarch64"
;;
# ... snip ...
;;
macosx-* | iphoneos-* | iphonesimulator-* | \
appletvos-* | appletvsimulator-* | \
watchos-* | watchsimulator-*)
case ${host} in
macosx-x86_64)
xcrun_sdk_name="macosx"
llvm_target_arch=""
SWIFT_HOST_TRIPLE="x86_64-apple-macosx${DARWIN_DEPLOYMENT_VERSION_OSX}"
SWIFT_HOST_VARIANT="macosx"
SWIFT_HOST_VARIANT_SDK="OSX"
SWIFT_HOST_VARIANT_ARCH="x86_64"

emacs: slime-repl hang if using read() or read-line() function

I am using Emacs 24.3.1 on Ubuntu 14.04, slime-20160402.549, GNU CLISP 2.4. Whenever i use read() or read-line() function in slime-repl, it will freeze after one or two input characters (e.g. "wa"),
; SLIME 2016-04-02
CL-USER> (read)
wa
Trying C-g it shows the error below:
Debugger entered--Lisp error: (quit)
accept-process-output(nil 0.01)
#[0 "\306\307!\306\310!\211\302L\266\211\211\300L\266\311\312J\301#\313\314\315\316\317D\316\nD\316\fD\320\257E\257!\266\321\322\323 \322\262\322\262\324!\325=\204J
slime-eval((swank:simple-completions "wa" (quote "COMMON-LISP-USER")))
slime-simple-completions("wa")
ac-source-slime-simple-candidates()
ac-candidates-1(((init . ac-slime-init) (candidates . ac-source-slime-simple-candidates) (candidate-face . ac-slime-menu-face) (selection-face . ac-slime-selection-face) (prefix . slime-symbol-start-pos) (symbol . "l") (document . ac-slime-documentation) (match . ac-source-slime-case-correcting-completions)))
ac-candidates()
ac-update(t)
ac-show-menu()
apply(ac-show-menu nil)
...
This problem does not happen in clisp REPL on command line.
Any helps?

How to use FFI:def-call-in in clisp

I have figured out how to make use of shared objects created from C code into Clisp using FFI:def-call-out but I am not able to figure out how to use FFI:Def-call-in.
I don't know the process and actually I am confused if clisp will also create some .so file that some C function can use or something else.
Can someone please explain a minimal working example for writing such callback functions ?
Example 32.7. Calling Lisp from C:
To sort an array of double-floats using the Lisp function SORT instead of the C library function qsort, one can use the following interface code sort1.c. The main problem is to pass a variable-sized array.
extern void lispsort_begin (int);
void* lispsort_function;
void lispsort_double (int n, double * array) {
double * sorted_array;
int i;
lispsort_begin(n); /* store #'sort2 in lispsort_function */
sorted_array = ((double * (*) (double *)) lispsort_function) (array);
for (i = 0; i < n; i++) array[i] = sorted_array[i];
free(sorted_array);
}
This is accompanied by sort2.lisp:
(DEFPACKAGE "FFI-TEST" (:use “COMMON-LISP” “FFI”))
(IN-PACKAGE "FFI-TEST")
(EVAL-WHEN (compile) (setq FFI:*OUTPUT-C-FUNCTIONS* t))
(FFI:DEF-CALL-IN lispsort_begin (:ARGUMENTS (n int))
(:RETURN-TYPE nil)
(:LANGUAGE :stdc))
(FFI:DEF-C-VAR lispsort_function (:type c-pointer))
(defun lispsort_begin (n)
(setf (cast lispsort_function
`(c-function
(:ARGUMENTS (v (c-ptr (c-array double-float ,n))))
(:RETURN-TYPE (c-ptr (c-array double-float ,n))
:malloc-free)))
#'sort2))
(defun sort2 (v)
(declare (type vector v))
(sort v #'<))
To test this, use the following test file sorttest.lisp:
(EVAL-WHEN (compile) (setq FFI:*OUTPUT-C-FUNCTIONS* t))
(FFI:DEF-CALL-OUT sort10
(:name "lispsort_double")
(:LANGUAGE :stdc)
(:ARGUMENTS (n int)
(array (c-ptr (c-array double-float 10)) :in-out)))
Now try
$ clisp-link create sort sort2.c sorttest.c
$ cc -O -c sort1.c
$ cd sort
$ ln -s ../sort1.o sort1.o
Add sort1.o to NEW_LIBS and NEW_FILES in link.sh. Create a file package.lisp containing the form
(MAKE-PACKAGE "FFI-TEST" :use '(“COMMON-LISP” “FFI”))
and add package.lisp to TO_PRELOAD in link.sh. Proceed:
$ cd ..
$ base/lisp.run -M base/lispinit.mem -c sort2.lisp sorttest.lisp
$ clisp-link add base base+sort sort
$ base+sort/lisp.run -M base+sort/lispinit.mem -i sort2 sorttest
> (sort10 10 '#(0.501d0 0.528d0 0.615d0 0.550d0 0.711d0
0.523d0 0.585d0 0.670d0 0.271d0 0.063d0))
#(0.063d0 0.271d0 0.501d0 0.523d0 0.528d0 0.55d0 0.585d0 0.615d0 0.67d0 0.711d0)
$ rm -r base+sort

not able to find package when running from SLIME, but from command line is ok

I'm running the teapot example from cl-opengl package. The only changes I've made are loading the required packages. It works fine when executed from unix shell (sbcl --load "3.cl"), but when I try to compile and load it through SLIME (C-c C-k) i get the error about package GLUT not found.
Curiously, the compiler chokes on the (defclass glut-teapot-window (glut:window).
What gives???
Here's a screenshot of what happens
Here's the code for 3.cl.
;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
;;; glut-teapot.lisp --- Simple usage of glut:solid-teapot.
(ql:quickload :cl-opengl)
(ql:quickload :cl-glu)
(ql:quickload :cl-glut)
;(setf *communication-style* :fd-handler)
(defclass glut-teapot-window (glut:window)
()
(:default-initargs :width 250 :height 250 :title "glut-teapot.lisp"
:mode '(:single :rgb :depth)))
(defmethod glut:display-window :before ((w glut-teapot-window))
(gl:clear-color 0 0 0 0)
(gl:cull-face :back)
(gl:depth-func :less)
(gl:disable :dither)
(gl:shade-model :smooth)
(gl:light-model :light-model-local-viewer 1)
(gl:color-material :front :ambient-and-diffuse)
(gl:enable :light0 :light1 :lighting :cull-face :depth-test))
(defmethod glut:display ((window glut-teapot-window))
(gl:load-identity)
(gl:translate 0 0 -5)
(gl:rotate 30 1 1 0)
(gl:light :light0 :position '(100 1000 1 0))
(gl:light :light0 :diffuse '(1.2 0.4 0.6 0))
(gl:light :light1 :position '(-100 1000 1 0))
(gl:clear :color-buffer :depth-buffer)
(gl:color 1 10 1)
(gl:front-face :cw)
(glut:solid-teapot 1.3)
;(glut:solid-torus 0.5 1.0 50 50)
;(glu:cylinder (glu:new-quadric) 0.5 0.5 0.5 20 20)
(gl:front-face :ccw)
(gl:flush))
(defmethod glut:reshape ((window glut-teapot-window) width height)
(gl:viewport 0 0 width height)
(gl:matrix-mode :projection)
(gl:load-identity)
(glu:perspective 50 (/ width height) 0.5 20)
(gl:matrix-mode :modelview)
(gl:load-identity))
(defmethod glut:keyboard ((window glut-teapot-window) key x y)
(declare (ignore x y))
(when (eql key #\Esc)
(glut:destroy-current-window)))
(defun glut-teapot ()
(glut:display-window (make-instance 'glut-teapot-window)))
(glut-teapot)
If you load the file, the Lisp system reads the file expression by expression and executes them after reading each single expression.
If you compile the file in a fresh Lisp, then it reads the expressions and compiles them. But it does not execute them. Thus it sees the quickload command, compiles it, but does not execute it. This OpenGL code is not loaded and the packages are not known to the compiler. But that makes sense: a compile usually should compile the file, not execute it. Lisp would execute the expressions then when you load the compiled fasl file.
There are two simple ways around it:
put the quickload operation in a separate file and compile/execute it before compiling the next file.
enclose the load operations in an EVAL-WHEN statement. (eval-when (:execute :load-toplevel :compile-toplevel) ... your code here ...).
The :compile-toplevel symbol means, that the code will be executed when the compiler sees it as a top-level form. Which it otherwise would not do. Thus you can have code in a file to compile which creates side effects - here loading other code.