cppzmq icon indicating copy to clipboard operation
cppzmq copied to clipboard

Example doesn't compile

Open louwers opened this issue 5 years ago • 6 comments

When trying to compile the provided example:

[bart@samadhi zmqtest]$ g++ --std=c++17 main.cc 
main.cc: In function ‘int main()’:
main.cc:9:19: error: ‘buffer’ is not a member of ‘zmq’
    sock.send(zmq::buffer(m), zmq::send_flags::dontwait);
                   ^~~~~~
main.cc:9:35: error: ‘zmq::send_flags’ has not been declared
    sock.send(zmq::buffer(m), zmq::send_flags::dontwait);

louwers avatar Jun 12 '19 17:06 louwers

Hi @louwers , what gcc version?

kurdybacha avatar Jun 21 '19 19:06 kurdybacha

@kurdybacha gcc/g++ 9.1.0

louwers avatar Jun 30 '19 09:06 louwers

I cannot reproduce this with gcc 9.1.1. Are you sure the include path is correct, and you are using the matching version of zmq.hpp?

sigiesec avatar Jul 24 '19 13:07 sigiesec

What would be the matching version? I experience the same problem. I am quite new to C++, so instead of compiling (and according to the docs installing the compiled artifacts to my system) I tried to use the C++ bindings shipped by the Arch Linux package manager. They are supposed to be version 4.3.1.

community/zeromq 4.3.1-2
    Fast messaging system built on sockets. C and C++ bindings. aka 0MQ, ZMQ.

It does find the installed bindings (before installing the package it complained that zmq.hpp was missing), but gives the exact error message from the initial post.

ghost avatar Jul 27 '19 13:07 ghost

Just checked the code files a bit. Indeed, the Arch provided header does not include send_flags.

It's between these two commits that it was added:

  • https://github.com/zeromq/cppzmq/blob/95d519fade9c43419f6fb4ade4d390c483dacf64/zmq.hpp
  • https://github.com/zeromq/cppzmq/blob/0ce8ef06d543288fa092745e399e914c1067a895/zmq.hpp

This would make sense, because between the two commits linked above the example code was added. According to the commit history, I'd say that the code example should run with version 4.4.1.

ghost avatar Jul 27 '19 13:07 ghost

This error also occurs when not specifying the version of c++ to the compiler. Adding -std=c++17 solved the issue for me.

sab24 avatar Oct 21 '19 13:10 sab24