从我的包管理器安装 Common Lisp 后如何使用 CLX/XLIB?

How do I use CLX/XLIB from Common Lisp after installing it from my package manager?

我正在尝试在学习 common lisp 的同时使用 CLX,因为我认为如果我有实际的、有形的、实用的结果,学习它会更有效。不幸的是,我无法让 CLX 工作。在 debian 中安装 clispclisp-module-clx 软件包后,我关注 the first bit of this tutorial

我想我只是严重误解了 clisp 的包/模块/等等加载系统,但我找不到任何资源来了解如何做到这一点。

foo.lisp:

(defun pop-up-window (life-time &optional (host ""))
  (let* ((display (xlib:open-display host))
         (screen (first (xlib:display-roots display)))
         (root-window (xlib:screen-root screen))
         (my-window (xlib:create-window
                      :parent root-window
                      :x 0
                      :y 0 
                      :width 200
                      :height 300)))
    (xlib:map-window my-window)
    (xlib:display-finish-output display)
    (format t "it should be here ~%")
    (sleep life-time)
    (xlib:destroy-window my-window)
    (xlib:close-display display)
)

(pop-up-window 10)

输出: there is no package with name "XLIB"

编辑:

我在代码的开头尝试了 (require "clx"),但我得到了 #<PACKAGE COMMON-LISP> is locked

很可能没有安装 CLX 系统。您可以自己下载存档并配置 ASDF to load the system, but the easiest route is to first install Quicklisp。然后,你可以执行:

(ql:quickload :clx)

这将下载、编译和加载所需的系统及其所有依赖项。每次重新启动 Lisp 环境时都应执行此步骤。一旦您需要多个库,您还应该定义自己的系统(例如在 ~/quicklisp/local-projects/ 中)并加载那个系统。