Thursday, July 23, 2015

My quick'ndirty installation of ZeroMq

ZeroMQ supports different languages and thus allow an easy interprocess data exchange between different programs.
For example a C program can easily exchange data with a Python or Java program.

Install ZeroMQ

To install ZeroMQ, is necessary to compile the source code and generate the library.

To do so, under ubuntu :
  1. sudo apt-get install build-essential
  2. sudo apt-get install libtool
  3. sudo apt-get install automake
  4. sudo apt-get install autoconf
  5. sudo apt-get install uuid-dev
  6. Download the tarball for the libsodium from the Libsodium website
  7. Extract the tarball in a directory
  8. go in the directory
  9. ./configure
  10. make
  11. sudo make install
  12. Download the tarball from the ZeroMQ website
  13. extract the tarball in a directory
  14. go in the directory
  15. ./configure
  16. make
  17. sudo make install
At this point is better to close all the terminals and re-open them.

On some systems is better to run :
sudo ldconfig to update the system library cache, otherwise it is requested a reboot of the machine.

Install Czmq

In order to bind the library with the C language is necessary to compile the library Czmq

  1.  git clone
  2.  cd czmq
  3.  ./
  4.  ./configure
  5.  make
  6.  sudo make install
  7.  sudo ldconfig

Use ZeroMQ in your code

Usually the libraries by default are placed in /usr/local/lib.

In order to use ZeroMQ in a project is enough to add to the linker phase the two main libraries, zeroMQ and the binding one.
Usually the name is the name of the library minus the "lib" part and the extension.
So for example, if the zeroMQ main library is called, the library name to be used in the linker will be zmq.

For example in a makefile :

LIB0MQ = -l zmq -l czmq      # define variable LIB0MQ containing the libraries directive
CC = gcc $(CFLAGS) -c
CC1 = gcc $(CFLAGS)

LD = $(LIB0MQ)
AS = as $(AFLAGS)

Then in the main preparation of the code :

projectName: $(projectName_objs)
$(CC1) -o $(APPNAME) $(projectName_objs) $(LD)

Cross compile for ARM

To cross compile for ARM, be sure to have installed a ARM toolchain other the packages described above, and when ready to compile ZeroMQ, starts with :

  1. ./configure --host=arm-none-linux-gnueabi
  2. make
Then copy the library on the target ... TBD

Compile the examples

To compile the examples is possible to use the build script provided with the examples.
However it can be overshooting.

I suggest to use this approach :

  1. copy the examples in a local directory
  2. run : gcc -Wall -g name_example.c -lzmq -o name_example
If everything is installed correctly, the program will execute.