methodmissing / rbczmq

Ruby extension that wraps the official high level ZeroMQ C API ( http://czmq.zeromq.org/ )
http://github.com/methodmissing/rbczmq
MIT License
125 stars 32 forks source link

ZMQ::Message#print fails with binding error #38

Open wokibe opened 9 years ago

wokibe commented 9 years ago

When executing the following ruby snippet: module ZMQ class Socket def dump_messages loop do message = recv_message message.print break unless rcvmore? end end end end

I get this result: dyld: lazy symbol binding failed: Symbol not found: _zmsg_dump Referenced from: /Users/kittekat/.rvm/gems/ruby-2.1.3@noko/extensions/x86_64-darwin-13/2.1.0-static/rbczmq-1.7.8/rbczmq_ext.bundle Expected in: flat namespace

The analysis showed, that this is related to a version mismatch of rbczmq and the czmq library. I am using a brew installed czmq version 2.2.0 (see issue 36), but the rbczmq 1.7.8 seems to use version 2.0.1 (result of calling ZMQ.czmq_version).

The source of Message#print references zmsg_dump (ext/rbczmq/message.c): static VALUE rb_czmq_message_print(VALUE obj) { ZmqGetMessage(obj); ZmqReturnNilUnlessOwned(message); zmsg_dump(message->message); return Qnil; }

But in the actual czmq socket.h the zmsg_dump has been depricated: // Deprecated method aliases

define zmsg_dump(s) zmsg_print(s)

Do you have plans to update rbczmq to the actual czmq?

Best regards Wokibe

wokibe commented 9 years ago

As ad hoc workaround I defined the following monkey patch

require 'rbczmq'

module ZMQ
  class Message
    def print
      msg = self
      frame = msg.first
      while frame
        frame.print
        frame = msg.next
      end
    end
  end

  class Socket
    def dump_messages
      loop do
        message = recv_message
        message.print
        break unless rcvmore?
      end
    end
  end
end

Best regards Wokibe