user-interfaceframeworkslispcommon-lispclozure-cl

How can I use a Common Lisp (Clozure CL) Library?


I'm learning Common Lisp (Clozure CL) on the Mac and would like to create a simple GUI. I have downloaded the "ltk" library from CLiki and put it into the project directory at the root level (I assumed I had to do this as I couldn't find instructions for a beginner).

Page 4 of the "LTK - a Lisp binding to the Tk toolkit" documentation says that the library should be compiled using (compile-file "ltk") before loading the library using (load "ltk"). However, I get this error message:

Error: File #P"/Users/myName/Desktop/lisp_experiments/GUI_EXAMPLE/ltk" not found While executing: CCL::FCOMP-FIND-FILE, in process Listener(4). Type cmd-. to abort, cmd-\ for a list of available restarts. Type :? for other options.

I also used the full file pathname and got the same error.

What am I doing wrong?

Thanks for your help.

Marc

ps - there are almost no noob tutorials about this sort of thing online that takes the user through the process step by step.


Solution

  • I have downloaded the "ltk" library from CLiki and put it into the project directory at the root level.

    Nowadays, this is a step that is seldom required, because libraries are easily accessible using Quicklisp (see also this gif). Basically, you should be able to install Quicklisp and run the following:

    (ql:quickload "ltk")
    

    The above downloads, compiles and install Lisp libraries, but not necessarily the required C libraries, which you might need to install separately. If the above works without problem, then the following should work too:

    (ltk:ltktest)
    

    Quicklisp relies on Lisp systems being described with ASDF (Another System Definition Facility). The best practices document is also interesting to read.

    In the case of LTK, you can see that ltk.asd only specifies one component, ltk.lisp. When you install the system named "LTK", quicklisp will do all the necessary work to install its dependencies, then compile and load ltk.lisp, as described in the manual.

    What is unclear is why your explicit compile-file failed.

    I found the ltk.lisp file on my machine; its pathname looks like:

    #P"/home/user/quicklisp/dists/quicklisp/software/ltk-20150113-http/ltk.lisp"
    

    Sure enough, calling compile-file with that pathname works and returns another pathname which ends in .fasl (the object format). Loading the returned pathname loads the library. Please provide more information about the error so that we can help you debug this problem.