chuckremes / ffi-rzmq

FFI bindings for ZeroMQ so the library can be used under JRuby and other FFI-compliant ruby runtimes
242 stars 62 forks source link

dyld: lazy symbol binding failed: Symbol not found: _randombytes #124

Closed janckerchen closed 7 years ago

janckerchen commented 7 years ago

my env

macOS Sierra
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
$ brew info zmq
zeromq: stable 4.2.2 (bottled), HEAD

what's this mean?

$ rake spec
/Users/jason/.rbenv/versions/2.3.1/bin/ruby -S rspec ./spec/context_spec.rb ./spec/device_spec.rb ./spec/message_spec.rb ./spec/multipart_spec.rb ./spec/nonblocking_recv_spec.rb ./spec/poll_spec.rb ./spec/pushpull_spec.rb ./spec/reqrep_spec.rb ./spec/socket_spec.rb ./spec/util_spec.rb
dyld: lazy symbol binding failed: Symbol not found: _randombytes
  Referenced from: /usr/local/lib/libzmq.dylib
  Expected in: flat namespace

dyld: Symbol not found: _randombytes
  Referenced from: /usr/local/lib/libzmq.dylib
  Expected in: flat namespace
janckerchen commented 7 years ago

change zeromq version to 4.0.2, same error but another symbol (_zmq_ctx_term).

$ rake spec
/Users/jason/.rbenv/versions/2.3.1/bin/ruby -S rspec ./spec/context_spec.rb ./spec/device_spec.rb ./spec/message_spec.rb ./spec/multipart_spec.rb ./spec/nonblocking_recv_spec.rb ./spec/poll_spec.rb ./spec/pushpull_spec.rb ./spec/reqrep_spec.rb ./spec/socket_spec.rb ./spec/util_spec.rb
............dyld: lazy symbol binding failed: Symbol not found: _zmq_ctx_term
  Referenced from: /usr/local/lib/libzmq.dylib
  Expected in: flat namespace

dyld: Symbol not found: _zmq_ctx_term
  Referenced from: /usr/local/lib/libzmq.dylib
  Expected in: flat namespace
janckerchen commented 7 years ago

change zeromq version to 3.2.5, same error but another symbol (_zmq_poll).

$ rake spec
/Users/jason/.rbenv/versions/2.3.1/bin/ruby -S rspec ./spec/context_spec.rb ./spec/device_spec.rb ./spec/message_spec.rb ./spec/multipart_spec.rb ./spec/nonblocking_recv_spec.rb ./spec/poll_spec.rb ./spec/pushpull_spec.rb ./spec/reqrep_spec.rb ./spec/socket_spec.rb ./spec/util_spec.rb
...............create streamer device and running...broke out of wait_for_device loop

dyld: lazy symbol binding failed: Symbol not found: _zmq_poll
  Referenced from: /usr/local/lib/libzmq.dylib
  Expected in: flat namespace

dyld: Symbol not found: _zmq_poll
  Referenced from: /usr/local/lib/libzmq.dylib
  Expected in: flat namespace
janckerchen commented 7 years ago

install zeromq(4.2.2) from source manually, "Symbol not found" is gone, but too many test case failed.

same error: "NameError: undefined local variable or method `rc' for #"

$ rake spec
/Users/jason/.rbenv/versions/2.3.1/bin/ruby -S rspec ./spec/context_spec.rb ./spec/device_spec.rb ./spec/message_spec.rb ./spec/multipart_spec.rb ./spec/nonblocking_recv_spec.rb ./spec/poll_spec.rb ./spec/pushpull_spec.rb ./spec/reqrep_spec.rb ./spec/socket_spec.rb ./spec/util_spec.rb
............FF.create streamer device and running...broke out of wait_for_device loop
F
create streamer device and running...broke out of wait_for_device loop

FF..................
An error occurred in an after(:all) hook.
  NameError: undefined local variable or method `rc' for #<ZMQ::Context:0x007fa0c705d1a0>
  occurred at /opt/dev_opensource/ffi-rzmq/lib/ffi-rzmq/context.rb:87:in `terminate'

FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF..................
An error occurred in an after(:all) hook.
  NameError: undefined local variable or method `rc' for #<ZMQ::Context:0x007fa0c72b67f8>
  occurred at /opt/dev_opensource/ffi-rzmq/lib/ffi-rzmq/context.rb:87:in `terminate'

.......
An error occurred in an after(:all) hook.
  NameError: undefined local variable or method `rc' for #<ZMQ::Context:0x007fa0c7d45ea8>
  occurred at /opt/dev_opensource/ffi-rzmq/lib/ffi-rzmq/context.rb:87:in `terminate'

FFFFFFFF.................
An error occurred in an after(:all) hook.
  NameError: undefined local variable or method `rc' for #<ZMQ::Context:0x007fa0c912f298>
  occurred at /opt/dev_opensource/ffi-rzmq/lib/ffi-rzmq/context.rb:87:in `terminate'

(more)
chuckremes commented 7 years ago

This is very odd.

With zeromq 4.2.2 installed I get the _randombytes error. I reinstalled brew install zeromq --with-libsodium and that solves that linking issue. However, now it complains about missing _zmq_ctx_term. Running nm -gU /path/to/libzmq.dylib clearly shows that symbol is exported and available.

This is a head scratcher... will work on it.

chuckremes commented 7 years ago

Fixed in release 2.0.5 (and in ffi-rzmq-core release 1.0.6).

Thank you for the report.

janckerchen commented 7 years ago

maybe something wrong in homebrew. I tried another zmq binding and encontered same error.

https://github.com/paddor/cztop/issues/14

Maybe macOS Sierra update cause this?

chuckremes commented 7 years ago

@janckerchen I think it might be a problem with the default home-brew formula which does NOT build zeromq with libsodium support. Try brew install zeromq --with-libsodium and try again.