{"id":24,"date":"2008-09-19T13:18:26","date_gmt":"2008-09-19T20:18:26","guid":{"rendered":"http:\/\/www.lothlorien.com\/kf6gpe\/?p=24"},"modified":"2010-12-05T14:58:21","modified_gmt":"2010-12-05T21:58:21","slug":"using-common-lisp-on-mac-os-x","status":"publish","type":"post","link":"https:\/\/www.lothlorien.com\/kf6gpe\/using-common-lisp-on-mac-os-x\/","title":{"rendered":"Using Common Lisp on Mac OS X"},"content":{"rendered":"<p>I&#8217;ve been a Lisp nut for years. I was first exposed to Lisp on my TRS-80, when I was about thirteen; Randy Beer had written a Lisp introduction in the March &#8217;83 issue of 80 Micro, and I remember reading it again and again. I&#8217;ve used various flavors of Lisp for exploratory prototyping programming over the years, and have enjoyed using both Scheme and Common Lisp.<\/p>\n<p>Getting a dialect of Common Lisp running on Mac OS X isn&#8217;t hard &#8212; in fact, if you&#8217;re just setting out, an excellent choice is <a href=\"http:\/\/www.lispworks.com\/downloads\/index.html\">LispWorks Personal Edition<\/a>. I&#8217;ve recently gotten to the point, however, where I&#8217;ve wanted to do some work with the Common Lisp Interface Manager, which isn&#8217;t supported in LispWorks Personal Edition under Mac OS X, and set out to configure a Common Lisp installation on my MacBook from the ground up.<\/p>\n<p>It wasn&#8217;t difficult, although it took some Googling to get all the pieces together; shortly after I finished, someone on the <a href=\"http:\/\/www.bayfp.org\/blog\/\">Bay Area Functional Programmer<\/a>&#8216;s mailing list asked about running Common Lisp on Mac OS X, and I put together my notes on the topic and replied. The list is fairly small &#8212; less than 300 members &#8212; and I promised them and myself that I&#8217;d organize the notes and provide them in a more accessible location.<\/p>\n<p>What follows is a step-by-step installation guide to installing <a title=\"Steel Bank Common Lisp\" href=\"http:\/\/www.sbcl.org\/\">Steel Bank Common Lisp<\/a> (SBCL) and <a title=\"McCLIM - A powerful GUI toolkit for Common Lisp\" href=\"http:\/\/common-lisp.net\/project\/mcclim\/\">McCLIM<\/a> on a PowerBook G4; I undertook this from the initial notes I took configuring the MacBook. I chose SBCL because it&#8217;s well-supported by the open source community and works well with McCLIM; I have nothing against other Common Lisp implementations, including <a title=\"Clozure CL\" href=\"http:\/\/trac.clozure.com\/openmcl\">Clozure<\/a>.\u00c2\u00a0<\/p>\n<p>A word of warning is in order: I&#8217;m comfortable with Common Lisp, but relatively unfamiliar with how Common Lisp programmers handle package distribution. I get the basic idea behind <a href=\"http:\/\/common-lisp.net\/project\/asdf-install\/\">ASDF<\/a>, of course, but I&#8217;m not seasoned in its use. Consequently, I had a get-things-working-and-clean-up-later mentality when I undertook my first SBCL-McCLIM configuration, and this largely remained when I wrote what follows. Other Lisp developers may have better ways to organize their working environments, and I&#8217;d welcome positive comments (drop me an email, and we&#8217;ll figure out how to incorporate your feedback).<\/p>\n<p>Starting out, you should have a relatively up-to-date Mac OS X box (I&#8217;ve done this on Mac OS X 10.4.x and 10.5.x systems). When you&#8217;re done, you will have installed <a title=\"Carbon Emacs Package\" href=\"http:\/\/homepage.mac.com\/zenitani\/emacs-e.html\">Carbon Emacs<\/a>, <a title=\"SLIME: The Superior Lisp Interaction Mode for Emacs\" href=\"http:\/\/common-lisp.net\/project\/slime\/\">SLIME<\/a>, <a title=\"About - Steel Bank Common Lisp\" href=\"http:\/\/www.sbcl.org\/\">SBCL<\/a>, and <a title=\"McCLIM - A powerful GUI toolkit for Common Lisp\" href=\"http:\/\/common-lisp.net\/project\/mcclim\/\">McCLIM<\/a>\u00c2\u00a0configured to work with the X Windows server Mac OS X provides, along with <a title=\"darcs\" href=\"http:\/\/darcs.net\/\">darcs<\/a>.\u00c2\u00a0<\/p>\n<h2><!--more-->Carbon Emacs<\/h2>\n<p>Carbon Emacs on Mac OS X provides you with an Emacs instance running as a Mac OS X application. I like it for general editing, as well as the obvious purpose of giving me a place to run SLIME and do my Lisp development.<\/p>\n<ol>\n<li>Get Carbon Emacs from its <a title=\"Carbon Emacs Package\" href=\"http:\/\/homepage.mac.com\/zenitani\/emacs-e.html\">home page<\/a>. If you need a version for a version of Mac OS X other than 10.5, check <a href=\"http:\/\/macwiki.sourceforge.jp\/emacs\/\">here<\/a>.<\/li>\n<li>Mount the disk image you download, and copy Emacs.app to your Applications folder.<\/li>\n<\/ol>\n<h2>Steel Bank Common Lisp<\/h2>\n<ol>\n<li>Download <a title=\"Download - Steel Bank Common Lisp\" href=\"http:\/\/www.sbcl.org\/platform-table.html\">SBCL<\/a>. Choose either X or P on this page for the X86 or PPC build, respectively.<\/li>\n<li>Unpack the distribution, and open a Terminal to the directory where you&#8217;ve unpacked the distribution.<\/li>\n<li>Install per the INSTALL instructions. I used the default options, placing SBCL in \/usr\/local by issuing:\n<pre>KF6GPEs-PB-G4:~\/Desktop\/sbcl-1.0.2-powerpc-darwin kf6gpe$ sudo sh\r\nPassword: &lt;entered password&gt;\r\n# INSTALL_ROOT=\/usr\/local sh install.sh<\/pre>\n<\/li>\n<\/ol>\n<p>At this point in time, you should be able to run SBCL from the shell.<\/p>\n<h2>SLIME<\/h2>\n<p>SLIME in Carbon Emacs is swell.<\/p>\n<ol>\n<li><a title=\"SLIME: The Superior Lisp Interaction Mode for Emacs\" href=\"http:\/\/common-lisp.net\/project\/slime\/\">Download<\/a> SLIME. I used CVS in the terminal, stashing the whole thing in a hidden directory. If you use a lot of emacs packages, you may well already have a directory for them, and you can put SLIME there as well.\n<pre>KF6GPEs-PB-G4:~ kf6gpe$ cvs -d :pserver:anonymous:anonymous@common-lisp.net:\/project\/slime\/cvsroot co slime\r\nKF6GPEs-PB-G4:~ kf6gpe$ mv slime ~\/.slime<\/pre>\n<\/li>\n<li>Wire SLIME up to your emacs installation. I followed the instructions in the SLIME documentation.<br \/>\nIn a nutshell, it says to add the following to your ~\/.emacs:\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0\u00c2\u00a0<\/p>\n<pre>   (setq inferior-lisp-program \"\/usr\/local\/bin\/sbcl\")\r\n   (add-to-list 'load-path \"~\/.slime\")\r\n   (require 'slime)\r\n   (slime-setup)<\/pre>\n<p>where<br \/>\n\/usr\/local\/bin\/sbcl is the path to SBCL you specified in the previous section, and<br \/>\n~\/.slime is the path to the slime directory you specified in the previous step.<\/li>\n<\/ol>\n<p>You can stop at this point if you don&#8217;t want to work with McCLIM; you have a working SBCL<br \/>\nenvironment using Carbon Emacs and SLIME. To use SLIME, start emacs from the Terminal or<br \/>\nCarbon Emacs and run SLIME using M-x slime.<\/p>\n<h2>darcs<\/h2>\n<p>Some of the stuff you need for McCLIM is kept in a darcs repository, so you first need to <a href=\"http:\/\/darcs.net\/\">get and install darcs<\/a>. I used one of the <a href=\"http:\/\/wiki.darcs.net\/DarcsWiki\/CategoryBinaries\">pre-built binaries<\/a>. Make sure that however you do this, darcs\u00c2\u00a0is in your path when you&#8217;re done installing, of course.<br \/>\n\u00c2\u00a0<\/p>\n<h2>McCLIM<\/h2>\n<p>I followed <a title=\"Getting Started with McCLIM\" href=\"http:\/\/mcclim.cliki.net\/GettingStarted\">these steps<\/a>\u00c2\u00a0\u00c2\u00a0to build and configure McCLIM from source.<\/p>\n<ol>\n<li>You&#8217;re going to use ASDF to get various Common Lisp packages, and you need a place to put the resulting files, as well as to tell SBCL where that place is.\u00c2\u00a0Make a directory ~\/lispsystems in your home directory, and configure SBCL by adding the following to your ~\/.sbclrc file:\n<pre>(require 'asdf)\r\n(push\u00c2\u00a0(truename \"~\/lispsystems\")\u00c2\u00a0asdf:*central-registry*)<\/pre>\n<\/li>\n<li>Fetch the McCLIM sources.\n<pre>KF6GPEs-PB-G4:~\/lispsystems kf6gpe$ cvs -z3 -d:pserver:anonymous:anonymous@common-lisp.net:\/project\/mcclim\/cvsroot co mcclim\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ ln -s mcclim\/mcclim.asd .\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ ln -s mcclim\/clim-examples.asd .<\/pre>\n<\/li>\n<li>Fetch McCLIM&#8217;s dependencies: the Common Lisp Library for X, spatial-trees, and flexichain:\n<pre>KF6GPEs-PB-G4:~\/lispsystems kf6gpe$ darcs get http:\/\/common-lisp.net\/~crhodes\/clx\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ ln -s clx\/clx.asd .\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ curl http:\/\/ftp.linux.org.uk\/pub\/lisp\/cclan\/spatial-trees.tar.gz &gt; spatial-trees.tar.gz\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ tar -xvzf spatial-trees.tar.gz\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ curl http:\/\/common-lisp.net\/project\/flexichain\/download\/flexichain_latest.tgz &gt; flexichain_latest.tgz\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ tar -xvzf flexichain_latest.tgz\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ ln -s spatial-trees-0.2\/spatial-trees.asd .\r\nKF6GPEs-PB-G4:~\/lispsystems kf6gpe$ ln -s flexichain_1.5.1\/flexichain.asd .<\/pre>\n<\/li>\n<li>Build the McCLIM system. Fire up Carbon Emacs, run SLIME using M-x slime, and enter:\n<pre>CL-USER&gt; (asdf:oos 'asdf:load-op :mcclim)<\/pre>\n<p>Be prepared to wait a while as the system builds for the first time.\u00c2\u00a0<\/li>\n<li>To see if everything works as expected, you can build the samples:\n<pre>CL-USER&gt; (asdf:oos 'asdf:load-op :clim-examples)<\/pre>\n<\/li>\n<li>To play with the samples:\n<pre>CL-USER&gt; (clim-demo::run-test 'clim-demo::demodemo)<\/pre>\n<\/li>\n<\/ol>\n<p>You also have the option of getting McCLIM using <a title=\"clbuild\" href=\"http:\/\/common-lisp.net\/project\/clbuild\/\">clbuild<\/a>, as <a title=\"McCLiki: Getting started using clbuild\" href=\"http:\/\/mcclim.cliki.net\/Getting%20started%20using%20clbuild\">this page<\/a>\u00c2\u00a0describes. That worked for me under Mac OS X 10.5, but did not under Mac OS X 10.4, and I didn&#8217;t bother to investigate what was different.\u00c2\u00a0<\/p>\n<p>Good luck and happy hacking!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been a Lisp nut for years. I was first exposed to Lisp on my TRS-80, when I was about thirteen; Randy Beer had written a Lisp introduction in the March &#8217;83 issue of 80 Micro, and I remember reading it again and again. I&#8217;ve used various flavors of Lisp for exploratory prototyping programming over &hellip; <a href=\"https:\/\/www.lothlorien.com\/kf6gpe\/using-common-lisp-on-mac-os-x\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using Common Lisp on Mac OS X<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[15],"class_list":["post-24","post","type-post","status-publish","format-standard","hentry","category-programming","tag-lisp"],"_links":{"self":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/24"}],"collection":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/comments?post=24"}],"version-history":[{"count":12,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/24\/revisions"}],"predecessor-version":[{"id":32,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/24\/revisions\/32"}],"wp:attachment":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/media?parent=24"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/categories?post=24"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/tags?post=24"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}