C Binding

High-level CZMQ API

The recommended binding for C developers is CZMQ, which provides a high-level API for ØMQ, with additional classes such as pollers, thread management, and security helpers.

Low-level C API

The native core API for ØMQ is supplied with libzmq. This is the definitive 'official' API for working with ØMQ, and is mapped into most language bindings.

Build Tools
Autotools: If you have installed libzmq to the standard library path (/usr/lib/) then in your configure.ac use the pkg-config macro:

PKG_CHECK_MODULES([libzmq], [libzmq])
CFLAGS="${libzmq_CFLAGS} ${CFLAGS}"
LIBS="${libzmq_LIBS} ${LIBS}"

CMake: If you have installed libzmq to the standard library path (/usr/lib/) then in your CMakeLists.txt use the following

FIND_LIBRARY(ZMQ_LIB libzmq)
TARGET_LINK_LIBRARIES(myExecOrLib ${ZMQ_LIB})

Note for releases 4.2.2 and earlier:
A bug in the distributable tarball generation omitted some CMake files that are necessary for the above to work.
Workarounds:
- use the Github tag tar'up instead to build and install, eg: https://github.com/zeromq/libzmq/archive/v4.2.2.tar.gz
- substitute libzmq with zmq in the above FIND_LIBRARY snippet

Makefiles: If you have installed libzmq to the standard library path (/usr/lib/) then in your Makefile just call pkg-config to get the right flags:

CFLAGS+=$(shell pkg-config —cflags libzmq)
LIBS+=$(shell pkg-config —libs libzmq)