私はこのようにはMac OS XにインストールされているzeromqMac OS XでZeroMQのC++バインディングをインストールするには?</p> <pre><code>g++ actualApp.cpp -lzmq </code></pre> <p>で
//
// 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>
#include <unistd.h>
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 ((void *) reply.data(), "World", 5);
socket.send (reply);
}
return 0;
}
ため
actualApp.cpp:6:19: error: zmq.hpp: No such file or directory
actualApp.cpp: In function ‘int main()’:
actualApp.cpp:13: error: ‘zmq’ has not been declared
actualApp.cpp:13: error: expected `;' before ‘context’
actualApp.cpp:14: error: ‘zmq’ has not been declared
actualApp.cpp:14: error: expected `;' before ‘socket’
actualApp.cpp:15: error: ‘socket’ was not declared in this scope
actualApp.cpp:18: error: ‘zmq’ has not been declared
actualApp.cpp:18: error: expected `;' before ‘request’
actualApp.cpp:21: error: ‘request’ was not declared in this scope
actualApp.cpp:28: error: ‘zmq’ has not been declared
actualApp.cpp:28: error: expected `;' before ‘reply’
actualApp.cpp:29: error: ‘reply’ was not declared in this scope
actualApp.cpp: At global scope:
actualApp.cpp:33: error: expected constructor, destructor, or type conversion at end of input
を取得 - ./configure
、make
、make install
を。
-lzmq
フラグを使用してエラーなしでCの例をコンパイルできます。
https://github.com/zeromq/cppzmqのこのC++ .hpp
ヘッダーはどのように使用しますか?
がどのようにC++コードをコンパイルする検索パスに含まれるローカル? –
私はこのようにCをしました - gcc actualApp.c -lzmq –
私はC++用に試していました - g ++ actualApp.cpp -lzmq –