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> Chris On Feb 8, 2010, at 5:46 PM, Chris Wong wrote: > From: Chris Wong <[email protected]> > > --- > bindings/ruby/extconf.rb | 4 +- > bindings/ruby/rbzmq.cpp | 73 +++++++++++++++++++++++---------------------- > 2 files changed, 39 insertions(+), 38 deletions(-) > > diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb > index d5778d0..cf50f62 100644 > --- a/bindings/ruby/extconf.rb > +++ b/bindings/ruby/extconf.rb > @@ -18,7 +18,7 @@ > > require 'mkmf' > dir_config('libzmq') > -have_library('libzmq') > -create_makefile("ruby") > +have_library('zmq') > +create_makefile("librbzmq") > > > diff --git a/bindings/ruby/rbzmq.cpp b/bindings/ruby/rbzmq.cpp > index fce749c..211685e 100644 > --- a/bindings/ruby/rbzmq.cpp > +++ b/bindings/ruby/rbzmq.cpp > @@ -69,8 +69,8 @@ static VALUE socket_initialize (VALUE self_, VALUE > context_, VALUE type_) > { > assert (!DATA_PTR (self_)); > > - if (strcmp (rb_obj_classname (context_), "Context") != 0) { > - rb_raise (rb_eArgError, "expected Context object"); > + if (strcmp (rb_obj_classname (context_), "Zmq::Context") != 0) { > + rb_raise (rb_eArgError, "expected Zmq::Context object"); > return Qnil; > } > > @@ -103,7 +103,7 @@ static VALUE socket_setsockopt (VALUE self_, VALUE > option_, > long optval = FIX2LONG (optval_); > > // Forward the code to native 0MQ library. > - rc = zmq_setsockopt (DATA_PTR (self_), NUM2INT (option_), > + rc = zmq_setsockopt (DATA_PTR (self_), NUM2INT (option_), > (void *) &optval, 4); > } > break; > @@ -113,8 +113,8 @@ static VALUE socket_setsockopt (VALUE self_, VALUE > option_, > case ZMQ_UNSUBSCRIBE: > > // Forward the code to native 0MQ library. > - rc = zmq_setsockopt (DATA_PTR (self_), NUM2INT (option_), > - (void *) StringValueCStr (optval_), RSTRING_LEN (optval_)); > + rc = zmq_setsockopt (DATA_PTR (self_), NUM2INT (option_), > + (void *) StringValueCStr (optval_), RSTRING_LEN (optval_)); > break; > > default: > @@ -170,7 +170,7 @@ static VALUE socket_send (VALUE self_, VALUE msg_, VALUE > flags_) > return Qnil; > } > memcpy (zmq_msg_data (&msg), RSTRING_PTR (msg_), RSTRING_LEN (msg_)); > - > + > rc = zmq_send (DATA_PTR (self_), &msg, NUM2INT (flags_)); > if (rc != 0 && errno == EAGAIN) { > rc = zmq_msg_close (&msg); > @@ -233,13 +233,14 @@ static VALUE socket_recv (VALUE self_, VALUE flags_) > } > > extern "C" void Init_librbzmq () > -{ > - VALUE context_type = rb_define_class ("Context", rb_cObject); > +{ > + VALUE cZmq = rb_define_module ("Zmq"); > + VALUE context_type = rb_define_class_under (cZmq, "Context", rb_cObject); > rb_define_alloc_func (context_type, context_alloc); > rb_define_method (context_type, "initialize", > (VALUE(*)(...)) context_initialize, 3); > > - VALUE socket_type = rb_define_class ("Socket", rb_cObject); > + VALUE socket_type = rb_define_class_under (cZmq, "Socket", rb_cObject); > rb_define_alloc_func (socket_type, socket_alloc); > rb_define_method (socket_type, "initialize", > (VALUE(*)(...)) socket_initialize, 2); > @@ -256,31 +257,31 @@ extern "C" void Init_librbzmq () > rb_define_method (socket_type, "recv", > (VALUE(*)(...)) socket_recv, 1); > > - rb_define_global_const ("HWM", INT2NUM (ZMQ_HWM)); > - rb_define_global_const ("LWM", INT2NUM (ZMQ_LWM)); > - rb_define_global_const ("SWAP", INT2NUM (ZMQ_SWAP)); > - rb_define_global_const ("AFFINITY", INT2NUM (ZMQ_AFFINITY)); > - rb_define_global_const ("IDENTITY", INT2NUM (ZMQ_IDENTITY)); > - rb_define_global_const ("SUBSCRIBE", INT2NUM (ZMQ_SUBSCRIBE)); > - rb_define_global_const ("UNSUBSCRIBE", INT2NUM (ZMQ_UNSUBSCRIBE)); > - rb_define_global_const ("RATE", INT2NUM (ZMQ_RATE)); > - rb_define_global_const ("RECOVERY_IVL", INT2NUM (ZMQ_RECOVERY_IVL)); > - rb_define_global_const ("MCAST_LOOP", INT2NUM (ZMQ_MCAST_LOOP)); > - rb_define_global_const ("SNDBUF", INT2NUM (ZMQ_SNDBUF)); > - rb_define_global_const ("RCVBUF", INT2NUM (ZMQ_RCVBUF)); > - > - rb_define_global_const ("NOBLOCK", INT2NUM (ZMQ_NOBLOCK)); > - rb_define_global_const ("NOFLUSH", INT2NUM (ZMQ_NOFLUSH)); > - > - rb_define_global_const ("P2P", INT2NUM (ZMQ_P2P)); > - rb_define_global_const ("SUB", INT2NUM (ZMQ_SUB)); > - rb_define_global_const ("PUB", INT2NUM (ZMQ_PUB)); > - rb_define_global_const ("REQ", INT2NUM (ZMQ_REQ)); > - rb_define_global_const ("REP", INT2NUM (ZMQ_REP)); > - rb_define_global_const ("XREQ", INT2NUM (ZMQ_XREQ)); > - rb_define_global_const ("XREP", INT2NUM (ZMQ_XREP)); > - rb_define_global_const ("UPSTREAM", INT2NUM (ZMQ_UPSTREAM)); > - rb_define_global_const ("DOWNSTREAM", INT2NUM (ZMQ_DOWNSTREAM)); > - > - rb_define_global_const ("POLL", INT2NUM (ZMQ_POLL)); > + rb_define_const (cZmq, "HWM", INT2NUM (ZMQ_HWM)); > + rb_define_const (cZmq, "LWM", INT2NUM (ZMQ_LWM)); > + rb_define_const (cZmq, "SWAP", INT2NUM (ZMQ_SWAP)); > + rb_define_const (cZmq, "AFFINITY", INT2NUM (ZMQ_AFFINITY)); > + rb_define_const (cZmq, "IDENTITY", INT2NUM (ZMQ_IDENTITY)); > + rb_define_const (cZmq, "SUBSCRIBE", INT2NUM (ZMQ_SUBSCRIBE)); > + rb_define_const (cZmq, "UNSUBSCRIBE", INT2NUM (ZMQ_UNSUBSCRIBE)); > + rb_define_const (cZmq, "RATE", INT2NUM (ZMQ_RATE)); > + rb_define_const (cZmq, "RECOVERY_IVL", INT2NUM (ZMQ_RECOVERY_IVL)); > + rb_define_const (cZmq, "MCAST_LOOP", INT2NUM (ZMQ_MCAST_LOOP)); > + rb_define_const (cZmq, "SNDBUF", INT2NUM (ZMQ_SNDBUF)); > + rb_define_const (cZmq, "RCVBUF", INT2NUM (ZMQ_RCVBUF)); > + > + rb_define_const (cZmq, "NOBLOCK", INT2NUM (ZMQ_NOBLOCK)); > + rb_define_const (cZmq, "NOFLUSH", INT2NUM (ZMQ_NOFLUSH)); > + > + rb_define_const (cZmq, "P2P", INT2NUM (ZMQ_P2P)); > + rb_define_const (cZmq, "SUB", INT2NUM (ZMQ_SUB)); > + rb_define_const (cZmq, "PUB", INT2NUM (ZMQ_PUB)); > + rb_define_const (cZmq, "REQ", INT2NUM (ZMQ_REQ)); > + rb_define_const (cZmq, "REP", INT2NUM (ZMQ_REP)); > + rb_define_const (cZmq, "XREQ", INT2NUM (ZMQ_XREQ)); > + rb_define_const (cZmq, "XREP", INT2NUM (ZMQ_XREP)); > + rb_define_const (cZmq, "UPSTREAM", INT2NUM (ZMQ_UPSTREAM)); > + rb_define_const (cZmq, "DOWNSTREAM", INT2NUM (ZMQ_DOWNSTREAM)); > + > + rb_define_const (cZmq, "POLL", INT2NUM (ZMQ_POLL)); > } > -- > 1.6.4.2 > _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
