Install & Compile ZeroMQ/ZMQ/0MQ on Ubuntu 12.04 32bit

14,843

Solution 1

After talking on a few IRC channels I have figured it out.

#### Build a single file with: ####
./c -p filename.cpp
g++ -o filename filename.opp -lzmq

#### Build all in folder ####
CCLIBS='-lzmq' ./build all

Solution 2

I found that I had to upgrade to ZeroMQ 3.2.x to get the examples to compile properly. The current version in the CentOS/EPEL repositories is 2.1.9, which doesn't work with the examples in the zguide. My example here was done on a CentOS 6.3 server.

yum remove zeromq zeromq-devel
wget http://download.zeromq.org/zeromq-3.2.2.tar.gz
tar zxvf zeromq-3.2.2.tar.gz && cd zeromq-3.2.2
./configure
make && make install
cd ~/zguide/examples/C
gcc -o hwclient hwclient.c -lzmq
Share:
14,843
Steven Leimberg
Author by

Steven Leimberg

Updated on June 29, 2022

Comments

  • Steven Leimberg
    Steven Leimberg almost 2 years

    I really want to use 0MQ for a personal project, but I am having a very tough time getting things to compile after installation

    Here is what I do:

    #### Install prerequisites without errors: ####
    $ sudo apt-get install libtool autoconf automake uuid-dev build-essential
    
    #### Get 0MQ: ####
    $ cd ~/Downloads
    $ wget http://download.zeromq.org/zeromq-3.2.1-rc2.tar.gz
    $ tar -xvzf zeromq-3.2.1-rc2.tar.gz
    
    #### Install 0MQ without errors: ####
    $ cd zeromq-3.2.1
    $ ./configure
    $ make
    $ sudo make install
    $ sudo ldconfig
    
    #### Get the imatix zguide: ####
    $ cd ~/Downloads
    $ wget https://github.com/imatix/zguide/tarball/master
    $ tar -xvzf master
    

    This is where I need help. Running "./build all" in the imatix "examples/C" and "examples/C++" folders just results in loads of errors. I have also tried compiling using the "./c" and "./c -p" commands in the "/examples/C/" & "/examples/C++/" directories respectively. I don't get errors, but they generate ".o" and ".opp" files. Are these executables? After compiling I have tried "chmod +x" and "chown 777" to no avail. Here is what I do:

    #### Generates hwclient.o ####
    $ cd imatix-zguide-a690f10/
    $ cd examples/C/
    $ ./c hwclient.c
    Compiling hwclient...
    $ ./hwclient.o
    bash: ./hwclient.o: Permission denied
    
    #### Generates hwclient.opp ###
    $ cd ../C++/
    $ ./c -p hwclient.cpp
    Compiling hwclient...
    $ ./hwclient.opp
    bash: ./hwclient.opp: Permission denied
    

    I have also tried compiling with g++ which just results in similar errors to running "./build all":

    $ g++ hwclient.cpp -o hwclient.exe
    /tmp/ccWFyLHw.o: In function `main':
    hwclient.c:(.text+0x16): undefined reference to `zmq_ctx_new'
    hwclient.c:(.text+0x3a): undefined reference to `zmq_socket'
    hwclient.c:(.text+0x52): undefined reference to `zmq_connect'
    hwclient.c:(.text+0x73): undefined reference to `zmq_msg_init_size'
    hwclient.c:(.text+0x7f): undefined reference to `zmq_msg_data'
    hwclient.c:(.text+0xb9): undefined reference to `zmq_msg_send'
    hwclient.c:(.text+0xc5): undefined reference to `zmq_msg_close'
    hwclient.c:(.text+0xd1): undefined reference to `zmq_msg_init'
    hwclient.c:(.text+0xed): undefined reference to `zmq_msg_recv'
    hwclient.c:(.text+0x10d): undefined reference to `zmq_msg_close'
    hwclient.c:(.text+0x12e): undefined reference to `zmq_close'
    hwclient.c:(.text+0x13a): undefined reference to `zmq_ctx_destroy'
    collect2: ld returned 1 exit status
    

    What is the next step/what am I missing? I have looked all over the 0MQ site & wiki but nobody else seems to have an issue. Am I making a noob mistake? Am I executing the ".o" or ".opp" files incorrectly? Are they even executables?

    Please help. I really want to use 0MQ!