[zeromq-dev] [PATCH] Add Zmq module namespace for ruby binding. Fix extconf.rb.

Martin Sustrik sustrik at 250bpm.com
Tue Feb 9 10:16:23 CET 2010

Chris Wong wrote:
> The ruby binding doesn't build correctly on Mac OS X Snow Leopard. This will fix the build.  However, I haven't fixed it enough so that it'd build with the top-level Makefile.  Will spend more time on it when I have some free cycle on it.  For now, this is needs to be built manually using.
> ruby extconf.rb --with-libzmq-lib=<directory of libzmq.a>

>> require 'mkmf'
>> dir_config('libzmq')
>> -have_library('libzmq')
>> -create_makefile("ruby")
>> +have_library('zmq')
>> +create_makefile("librbzmq")

McClain Looney proposed following solution:

  require 'mkmf'
+if have_library('libzmq', 'zmq_init')
+  puts "cool, I found your zmq install..."
+  create_makefile("zmq")
+  raise "Couldn't find zmq library. try setting --with-zmq-dir=<path> 
to tell me where it is."

I have no idea how Ruby plugin system works, so I cannot judge what's 

>> +    VALUE cZmq = rb_define_module ("Zmq");
>> +    VALUE context_type = rb_define_class_under (cZmq, "Context", rb_cObject);

Ruby API should definitely be changed to make the usage of 0MQ as 
intuitive an easy for Ruby developers as possible. The current way of 
creating socket, for instance, seems to miss the namespacing:

s = Socket.new(ctx, REP);

It should probably rather look like this:

s = ZMQ.Socket.new(ctx, ZMQ.REP);

However, changing API is pretty serious matter and so it should be done 
_once only_. Thus, before getting further it would be great if there was 
some discussion on the topic among Ruby developers to point out possible 
problems and drawbacks.


More information about the zeromq-dev mailing list