zeromq / cppzmq

Header-only C++ binding for libzmq
http://www.zeromq.org
MIT License
1.97k stars 757 forks source link

I cant run the demo program #431

Closed Flatfish99 closed 4 years ago

Flatfish99 commented 4 years ago

include

int main() { zmq::context_t ctx; zmq::socket_t sock(ctx, zmq::socket_type::push); sock.bind("inproc://test"); sock.send(zmq::str_buffer("Hello, world"), zmq::send_flags::dontwait); }

when i try to complie this

Scanning dependencies of target demo [ 50%] Building CXX object CMakeFiles/demo.dir/main.cpp.o [100%] Linking CXX executable demo [100%] Built target demo (base) localhost:build landkyani$ make Scanning dependencies of target demo [ 50%] Building CXX object CMakeFiles/demo.dir/main.cpp.o /Users/landkyani/github/cppzmq-master/demo/main.cpp:6:34: error: no member named 'socket_type' in namespace 'zmq'; did you mean 'socket_t'? zmq::socket_t sock(ctx, zmq::socket_type::push);


                                 socket_t
/usr/local/include/zmq.hpp:2073:7: note: 'socket_t' declared here
class socket_t : public detail::socket_base
      ^
/Users/landkyani/github/cppzmq-master/demo/main.cpp:6:47: error: no member named
      'push' in 'zmq::socket_t'
    zmq::socket_t sock(ctx, zmq::socket_type::push);
                            ~~~~~~~~~~~~~~~~~~^
/Users/landkyani/github/cppzmq-master/demo/main.cpp:8:53: error: no member named
      'send_flags' in namespace 'zmq'
    sock.send(zmq::str_buffer("Hello, world"), zmq::send_flags::dontwait);
                                               ~~~~~^
/Users/landkyani/github/cppzmq-master/demo/main.cpp:8:20: error: no member named
      'str_buffer' in namespace 'zmq'
    sock.send(zmq::str_buffer("Hello, world"), zmq::send_flags::dontwait);
              ~~~~~^
4 errors generated.
make[2]: *** [CMakeFiles/demo.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/demo.dir/all] Error 2
make: *** [all] Error 2
gummif commented 4 years ago

Did you set the standard to at least C++11?

Flatfish99 commented 4 years ago

Did you set the standard to at least C++11?

I'm a beginer and I'm sorry for the low-level question.I have fixed it .thank you for your help .

nilsmelchert commented 3 years ago

@gummif, @Flatfish99 So was the solution simply to use C++11 or later?

I am asking, because I am experiencing the same issue, although I am using C++11

error: no member named 'send_flags' in namespace 'zmq'
error: no member named 'buffer' in namespace 'zmq'
gummif commented 3 years ago

You can check the macros in the zmq.hpp header if they are defined. Are you using an old compiler?

nilsmelchert commented 3 years ago

It was actually a version conflict. Had the wrong libzmq.