Friday, June 17, 2011

Making ZeroMQ jar for Mac

Making ZeroMQ jar for Mac was one of the most painful tasks I have done. And here is my attempt to save effort  of others for the same task.

STEP 1
Get latest version of zmq for POSIX systems from http://www.zeromq.org/intro:get-the-software
Say the file you got is zeromq-2.1.7.tar.gz., place this in your home directory( not required, any directory is fine as an example I am taking home directory).
Unzip the file and you will get a directory zeromq-2.1.7
Then run following commands:
     1 cd ~/zeromq-2.1.7
     2 ./autogen.sh
     3 ./configure
     4 make
     5 sudo make install


STEP 2
Now before we proceed you should get pkg-config, if you already have, then ignore this step.
Get pkg-config from http://pkgconfig.freedesktop.org/releases/pkg-config-0.22.tar.gz
Unzip this in home directory and pkg-config-0.22 will be created.
Run the following commands:
     1 cd ~/pkg-config-0.22
     2 ./configure --prefix=/usr/local/pkg-config-0.22 --datarootdir=/usr/share
     3 make
     4 sudo make install
     5 export PATH=$PATH:/usr/local/pkg-config-0.22/bin

STEP 3
Now download java jzmq from https://github.com/zeromq/jzmq and place it in folder ~/jzmq (not necessary, i am taking it for cake of example)
Run the following
     1 cd ~/jzmq
     2 export JAVA_HOME=`/usr/libexec/java_home`
     3 ./autogen.sh
     4 ./configure
     5 make
     6 sudo make install

This will make zmq.jar in /usr/local/share/java/

Problems you might face:
  While running ./autogen.sh
     * autogen.sh: error: could not find pkg-config. pkg-config is required to run autogen.sh
        -- you should complete STEP 2
  While running ./configure
     * ./configure: line 15180: syntax error near unexpected token `newline'
      ./configure: line 15180: ` PKG_CHECK_MODULES('
        --you missed STEP 2.2
    * configure: error: cannot link with -lzmq
        -- this happens when you forget to do STEP1.4,1.5
    * configure: error: the JAVA_HOME environment variable must be set to your JDK location
        -- repeat STEP 3.2