在Ubuntu 12.04 32bit上安装和编译ZeroMQ / ZMQ / 0MQ

问题描述 投票:7回答:2

我真的想将0MQ用于个人项目,但是我很难安装完成后编译

这是我做的:

#### 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

这是我需要帮助的地方。在imatix“examples / C”和“examples / C ++”文件夹中运行“./build all”只会导致大量错误。我还尝试分别使用“/ examples / C /”和“/ examples / C ++ /”目录中的“./c”和“./c -p”命令进行编译。我没有错误,但他们生成“.o”和“.opp”文件。这些可执行文件是?编译后我尝试了“chmod + x”和“chown 777”无济于事。这是我做的:

#### 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

我也尝试使用g ++进行编译,这只会导致运行“./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

下一步是什么/我错过了什么?我已经浏览了0MQ网站和维基,但似乎没有其他人有问题。我做了一个菜鸟错误吗?我是否错误地执行了“.o”或“.opp”文件?它们甚至是可执行文件吗?

请帮忙。我真想用0MQ!

c++ c ubuntu compiler-errors zeromq
2个回答
8
投票

我发现我必须升级到ZeroMQ 3.2.x才能正确编译示例。 CentOS / EPEL存储库中的当前版本是2.1.9,它不适用于zguide中的示例。我的例子是在CentOS 6.3服务器上完成的。

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

6
投票

在谈了几个IRC频道后,我已经弄明白了。

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

#### Build all in folder ####
CCLIBS='-lzmq' ./build all
© www.soinside.com 2019 - 2024. All rights reserved.