如何在Mac OS X 10.9上安装ZeroMQ,以便在C/ c++程序中使用?

时间:2022-04-30 10:40:29

I'm trying to receive information from an 0MQ Socket in C or C++, but therefore I have to include zmq.h. By downloading the 0MQ software from their website and including this file. Xcode gives the following error:

我正在尝试从C或c++中的一个0MQ套接字接收信息,但因此我必须包含zmq.h。通过从他们的网站下载0MQ软件,包括这个文件。Xcode给出如下错误:

Undefined symbols for architecture x86_64: "_zmq_init", referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

架构x86_64的未定义符号:“_zmq_init”,从main中引用:_main。o ld:没有找到用于架构x86_64 clang的符号:错误:链接器命令失败,退出代码1(使用-v查看调用)

When installing ZeroMQ using brew I get the same error. Is there anyone who know a workaround?

当使用brew安装ZeroMQ时,我得到了相同的错误。有谁知道变通方法吗?

1 个解决方案

#1


2  

The problem here is that you aren't linking the ZMQ library correctly.

这里的问题是您没有正确地链接ZMQ库。

You need to build the library once you've downloaded it (they include all the make scripts you need). Once you have that, you will need to link them to the compiler. I'm not too familiar with XCode, but using gcc it would look something like this:

下载后,您需要构建这个库(它们包括您需要的所有make脚本)。一旦有了这些,就需要将它们链接到编译器。我不太熟悉XCode,但是使用gcc它看起来是这样的:

-L/path/to/zmq/library -lzmq

ZeroMQ is really beautiful though. I've used it on Linux/Windows. Hope you get it working!

ZeroMQ真的很美。我在Linux/Windows上使用过。希望你能成功!

#1


2  

The problem here is that you aren't linking the ZMQ library correctly.

这里的问题是您没有正确地链接ZMQ库。

You need to build the library once you've downloaded it (they include all the make scripts you need). Once you have that, you will need to link them to the compiler. I'm not too familiar with XCode, but using gcc it would look something like this:

下载后,您需要构建这个库(它们包括您需要的所有make脚本)。一旦有了这些,就需要将它们链接到编译器。我不太熟悉XCode,但是使用gcc它看起来是这样的:

-L/path/to/zmq/library -lzmq

ZeroMQ is really beautiful though. I've used it on Linux/Windows. Hope you get it working!

ZeroMQ真的很美。我在Linux/Windows上使用过。希望你能成功!