错误:尚未声明'zmq'
error: 'zmq' has not been declared
在构建/编译时,我收到以下错误:
C:Ethemain.cpp: In function 'int main()':
C:Ethemain.cpp:11:4: error: 'zmq' has not been declared
C:Ethemain.cpp:11:19: error: expected ';' before 'context'
C:Ethemain.cpp:12:4: error: 'zmq' has not been declared
C:Ethemain.cpp:12:18: error: expected ';' before 'socket'
C:Ethemain.cpp:14:4: error: 'zmq' has not been declared
main.cpp:
#include <zmq.h>
#include <iostream>
#include <string>
int main()
{
std::string tip;
std::cout << "Enter Target IP: ";
std::cin >> tip;
zmq::context_t context (1);
zmq::socket_t socket (context, ZMQ_REQ);
std::cout << "Connecting to " << tip << std::endl;
zmq::socket.connect ("tcp://"+tip+":5555");
return 0;
}
有人知道我该怎么解决这个问题吗?
您需要添加#include <zmq.hpp>
,这将包括libzmq的C++api。但是,在zmqverions2.x版本中,它包含在安装中,而现在在zmq-3.x.y版本中,不再随库提供它,正如您可以从中看到的那样http://github.com/zeromq/zeromq3-x/raw/master/NEWS
C++api被排除在核心库之外,因为zeromq的"少即是多"策略。它仍然可以从以下位置下载:https://github.com/zeromq/cppzmq/blob/master/zmq.hpp
这个头是围绕C API zeromq的所有C结构和函数编写的,因此整个C++API是一个单独的头文件。可从上面的链接下载。
如果您自己编写zmq.h,它应该是"zmq.h"
。
相关文章:
- #ifdef和未声明的标识符
- 未声明的标识符编译暗黑破坏神 2 程序"muleview"
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- Google protobuf 时间戳未声明标识符,在 Windows 上具有C++
- 在气泡排序程序中未声明错误功能
- 我在范围内未声明的错误类有问题
- 使用未声明的标识符"sqrt"?
- 我包含了<winuser.h>,但编译器在MonitorFromWindow上抛出"未声明"
- 对类 (C++) 中的私有变量使用未声明的标识符
- 我的代码中有错误,未声明的标识符
- 未定义的标识符/未声明
- 错误:在 C++ 'std'使用未声明的标识符
- 在编译器之前检测未声明的标识符
- 使用未声明的标识符'temp'
- 使用未声明的标识符"yylex"和"yyin"?
- 使用"class"关键字,后跟未声明的标识符
- 未声明的标识符错误,但变量定义正确 (?)
- C2065 'cout':未声明的标识符
- 在此范围内未声明错误"Clreol"
- C++模板模板参数中未声明的标识符