Setting up 0MQ for Clojure on OSX: Redux

One of my favorite aspects of the Clojure community is how quickly it evolves.

  1. Install the core ZeroMQ libraries:
     brew install zeromq 
  2. Homebrew recently updated its formula for pkg-config to the require 0.25, so simply install it:
     brew install pkg-config 
  3. Link pkg.m4 into /usr/share/aclocal so jzmq can find it:
     sudo ln -s /usr/local/share/aclocal/pkg.m4 /usr/share/aclocal/pkg.m4 
  4. Build jzmq
    git clone git://github.com/zeromq/jzmq.git
    cd jzmq
    ./autogen.sh
    ./configure
    make
    sudo make install
  5. A new trick: Use maven to install the required Zmq.jar into your local repository (located at $HOME/.m2/repositories by default):
    mvn install:install-file -Dfile=src/Zmq.jar -DgroupId=org.zeromq -DartifactId=jzmq -Dversion=2.0.8-SNAPSHOT -Dpackaging=jar
  6. At this point, the steps from the previous article take over. Edit your project.clj for the install.
    (defproject my-project "1.0.0-SNAPSHOT"
      :description "FIXME: write"
      :dependencies [[org.clojure/clojure "1.2.0"]
                     [org.clojure/clojure-contrib "1.2.0"]
                     [org.zeromq/jzmq "2.0.8-SNAPSHOT"]
                     [org.clojars.mikejs/clojure-zmq "2.0.7-SNAPSHOT"]]
      :dev-dependencies [[swank-clojure "1.2.1"]]
      ; This sets the 'java.library.path' property
      ; so Java can find the ZeroMQ dylib
      :native-path "/usr/local/lib")
  7. Build the project dependencies:
     lein deps 
  8. Enjoy!

This process is much refined over the original. It's simple enough now that I was able to wrap everything up into a single installer script, available as a gist on Github. It installs the supporting libraries via Homebrew, builds jzmq, then pulls down a simple test app to verify that everything is installed correctly.

blog comments powered by Disqus