Reputation: 43
When building/compiling I am getting this error:
C:\Ethe\main.cpp: In function 'int main()':
C:\Ethe\main.cpp:11:4: error: 'zmq' has not been declared
C:\Ethe\main.cpp:11:19: error: expected ';' before 'context'
C:\Ethe\main.cpp:12:4: error: 'zmq' has not been declared
C:\Ethe\main.cpp:12:18: error: expected ';' before 'socket'
C:\Ethe\main.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;
}
Anyone got any ideas on how i can fix this?
Upvotes: 3
Views: 4194
Reputation: 4411
You need to add #include <zmq.hpp>
This will include the C++ api of libzmq. However, in the zmq verions 2.x version it was included with the install, nowadays in the zmq-3.x.y version it is not shipped with the library anymore, as you can see from http://github.com/zeromq/zeromq3-x/raw/master/NEWS
The C++ api was excluded from the core library since the less is more strategy from zeromq. It is still downloadable from: https://github.com/zeromq/cppzmq/blob/master/zmq.hpp
This header is written around all C structures and functions the C API zeromq, therefore the entire C++ API is a single headerfile. Downloadable from the link above.
Upvotes: 8