When I try to run this simple program (https://zeromq.org/get-started/?language=cpp&library=zmqpp#)
#include <zmqpp/zmqpp.hpp>
#include <string>
#include <iostream>
#include <chrono>
#include <thread>
using namespace std;
int main(int argc, char *argv[]) {
const string endpoint = "tcp://*:5555";
// initialize the 0MQ context
zmqpp::context context;
// generate a pull socket
zmqpp::socket_type type = zmqpp::socket_type::reply;
zmqpp::socket socket (context, type);
// bind to the socket
socket.bind(endpoint);
while (1) {
// receive the message
zmqpp::message message;
// decompose the message
socket.receive(message);
string text;
message >> text;
//Do some 'work'
std::this_thread::sleep_for(std::chrono::seconds(1));
cout << "Received Hello" << endl;
socket.send("World");
}
}
I get this error:
master/pubSub/pub.cpp:3:10: fatal error: 'zmqpp/zmqpp.hpp' file not found
#include <zmqpp/zmqpp.hpp>
I also get this as well:
Uncaught TypeError: Callback must be a function. Received undefined
fs.js:135
Obviously, this seems to emerge from the fact that I have not installed ZMQ Correctly. I tried to install it two ways:
Failed Method #1:
- Installed Homebrew (https://brew.sh/)
- Then in terminal: brew install zmq
Failed Method #2
- Downloaded cppzmq zip file (https://github.com/zeromq/cppzmq). Unzipped this file titled cppzmq-master
- Downloaded Cmake
- Installed Cmake in terminal: brew install cmake
- In terminal, changed directory to cppzmq-master
- mkdir build
- cd build
- cmake ..
- sudo make -j4 install
Not sure where I went wrong; still new to this, so feedback is much appreciated!
ZMQ Website for Reference: https://zeromq.org/
Sources