Installing CLSQL on OS X
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://git.b9.com/clsql.git
MacPorts hides the MySQL libraries and headers somewhere in /opt
so you need to make some tweaks. Change db-mysql/Makefile
, by adding:
-I/opt/local/include/mysql5/mysql
to CFLAGS
(first appearance) and:
-L/opt/local/lib/mysql5/mysql/
to LDFLAGS
(also first appearance). You’re now ready to build the interface. Run make
from the clsql
directory:
make
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)
EOF
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!