关于此事,我在互联网上找到了几个答案,但没有一个对我有用(顺便说一句,我正在使用Windows)。
这是zeroMQ网站上的hello世界服务器示例:
//
// Hello World server in C++
// Binds REP socket to tcp://*:5555
// Expects "Hello" from client, replies with "World"
//
#include <zmq.hpp>
#include <string>
#include <iostream>
#ifndef _WIN32
#include <unistd.h>
#else
#include <windows.h>
#define sleep(n) Sleep(n)
#endif
int main () {
// Prepare our context and socket
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_REP);
socket.bind ("tcp://*:5555");
while (true) {
zmq::message_t request;
// Wait for next request from client
socket.recv (&request);
std::cout << "Received Hello" << std::endl;
// Do some 'work'
sleep(1);
// Send reply back to client
zmq::message_t reply (5);
memcpy (reply.data (), "World", 5);
socket.send (reply);
}
return 0;
}
现在,我有了zmq.hpp,并且已经在链接器设置上链接了libzmq.lib(我在Code :: Blocks上使用GCC编译器),并且出现了此错误(在zmq.hpp中):
构建消息
我认为这与库有关。我尝试过:
#pragma comment (lib, "libzmq.lib")