[slime-devel] Re: Compilation and loading procedure
Zach Beane
xach at xach.com
Tue May 1 17:50:42 UTC 2007
"Mikhail Shevchuk" <mikhail.shevchuk at gmail.com> writes:
> I have a simple program, that connects to IRC using cl-irc package and
> I wish I could compile it using SLIME. If I hit C-c C-k I get the
> following error:
>
> -+ Errors (1)
> `-- READER-ERROR at 610 (line 24, column 40) on #<SB-SYS:FD-STREAM
> for "file /home/mico/Sources/lisp/utrbot/ircbot.lisp" {B05E531}>:
> package "CL-IRC" not found
>
> There is a first usage of cl-irc there:
>
> (defvar *irc-connection* (cl-irc:connect :nickname "sbclbot"
> :server "irc.tomsk.ru"
> :port 6667))
>
This doesn't have much to do with slime.
You should arrange to have the right packages loaded at the right
time. An ASDF system file is an easy way to do that. Specifically, I
would create a file called ircbot.asd that looked like this:
(asdf:defsystem #:ircbot
:depends-on (#:cl-irc)
:components ((:file "ircbot")))
Once you have created ircbot.asd, you can use (require 'ircbot) from
the REPL, or M-x slime-load-system, or ,load-system from the REPL. It
will ensure that the cl-irc system is loaded before trying to compile
your ircbot.lisp file, which depends on the cl-irc package existing at
compile time.
> At the top of that file (ircbot.lisp) I call:
> (require 'asdf)
> (asdf:oos 'asdf:load-op 'cl-irc)
Remove these lines from your source file.
> When I run this program using the same sbcl (1.0.5) it works fine - it
> compiles with no errors or warnings and do what it has to. I guess the
> cl-irc package doesn't load properly on C-c C-k or I am missing
> something. After I evaluate the (asdf:oos ... command in the REPL
> manually and compile the file using C-c C-k it loads and works fine.
After it's loaded once via the ASDF steps, recompiling with C-c C-k
will also work, since all the necessary packages are now available.
I often start projects as a single file that I can compile and load
from a freshly started Lisp via C-c C-k. But as soon as the project
grows to depend on other systems, or is best organized into multiple
files, I create an ASDF system file and use that to initialize things
correctly.
Zach
More information about the slime-devel
mailing list