c++ - 在 Ubuntu 12.04 32 位上安装和编译 ZeroMQ/ZMQ/0MQ

标签 c++ c ubuntu compiler-errors zeromq

我真的很想将 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 站点和 wiki,但似乎没有其他人有问题。我犯了一个菜鸟错误吗?我是否错误地执行了“.o”或“.opp”文件?它们甚至是可执行文件吗?

请帮忙。我真的很想用0MQ!

最佳答案

我发现我必须升级到 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

关于c++ - 在 Ubuntu 12.04 32 位上安装和编译 ZeroMQ/ZMQ/0MQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12901871/

相关文章:

c++ - 模板特化不适用于派生类

c++ - 具有自动返回类型参数推导的可变参数模板

c++ - 显示集合的第一个元素

c - 如何从 NSURL 获取结构文件?

iphone - 使用文本文件实时绘图

ubuntu - Docker 容器没有第二次启动(iptables)

c++ - 获取 constexpr 全局变量(不是静态成员)的链接器符号

c - 错误的文件描述符

eclipse - 编辑 eclipse.ini (OS Ubuntu 12.04 LTS) 后无法保存。如何在 eclipse.ini 文件或任何其他 .ini 文件中进行更改?

python - 制作快速脚本来搜索 bash 历史 - 我怎样才能让它更健壮?