Installing CLSQL on OS X

Published at: 22.XI.2008 09:03 CET
Categories: english, lisp, osx

Here’s my recipe to get CLSQL to work on my OS X development environment. I already had SBCL and MySQL 5 installed using MacPorts.

First you need to get the code:

git clone git://

MacPorts hides the MySQL libraries and headers somewhere in /opt so you need to make some tweaks. Change db-mysql/Makefile, by adding:


to CFLAGS (first appearance) and:


to LDFLAGS (also first appearance). You’re now ready to build the interface. Run make from the clsql directory:


This should finish without errors. Now you can install CLSQL with the rest of you ASDF systems (I prefer to keep them in my home location):

cp -rp clsql ~/.sbcl/site
(cd ~/.sbcl/system; ln -s ../site/clsql/*.asd .)

To allow CLSQL to find the mysqlclient library you need to create /etc/clsql-init.lisp:

echo '(clsql:push-library-path #p"/opt/local/lib/mysql5/mysql/")' > /etc/clsql-init.lisp

Finally you can run the included test suite to see if it all works fine. Run the tests (my mysql root user doesn’t have a password on my development machine) as follows:

mysqladmin5 create clsql-test
echo '((:mysql ("localhost" "clsql-test" "root" "")))' > ~/.clsql-test.config
sbcl << EOF
(require 'asdf)
(asdf:oos 'asdf:test-op :clsql)

Not as easy as installing it on a Debian system (apt-get install cl-sql) but not very hard either.

Happy MySQL hacking with Common Lisp on OS X!