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

Cannot open libzmq.so.3 #39

Closed 0x0badc0de closed 9 years ago

0x0badc0de commented 9 years ago

While trying to build with 'rake' got following: /usr/bin/ruby22 -w -I"lib:test" -I"/usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib" "/usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/rake_testloader.rb" "test/**/test*.rb" /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require': libzmq.so.3: cannot open shared object file: No such file or directory - /mnt/disk/soft/rbczmq/lib/rbczmq_ext.so (LoadError) from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /mnt/disk/soft/rbczmq/lib/zmq.rb:9:in rescue in <top (required)>' from /mnt/disk/soft/rbczmq/lib/zmq.rb:6:in<top (required)>' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /mnt/disk/soft/rbczmq/test/helper.rb:3:in <top (required)>' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /mnt/disk/soft/rbczmq/test/socket/test_dealer_socket.rb:3:in<top (required)>' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:10:in block (2 levels) in <main>' from /usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:9:ineach' from /usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:9:in block in <main>' from /usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:inselect' from /usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `

' rake aborted! Command failed with status (1): [ruby -w -I"lib:test" -I"/usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib" "/usr/lib64/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/rake_testloader.rb" "test/**/test*.rb" ]

Tasks: TOP => default => test

(See full trace by running task with --trace)

If installed with 'gem install rbczmq' or 'bundle install' from rails project, cannot run unless LD_LIBRARY_PATH contains path to libzmq.so.3 installed with rbczmq. $ irb irb(main):001:0> require 'zmq' LoadError: libzmq.so.3: cannot open shared object file: No such file or directory - /home/maks/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/lib/rbczmq_ext.so from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /home/maks/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/lib/zmq.rb:9:in rescue in <top (required)>' from /home/maks/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/lib/zmq.rb:6:in<top (required)>' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in require' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:inrescue in require' from /usr/lib64/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in require' from (irb):1 from /usr/bin/irb:11:in

' $ find ~/.gem/ -name libzmq.so.3 /home/maks/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/ext/rbczmq/dst/lib/libzmq.so.3 /home/maks/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/ext/zeromq/src/.libs/libzmq.so.3 $ LD_LIBRARY_PATH=/home/maks/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/ext/rbczmq/dst/lib irb irb(main):001:0> require 'zmq' => true

Send/recv work after it. Tried on 'Gentoo' in case it matters.

methodmissing commented 9 years ago

Thanks for flagging, will take a look shortly

abargnesi commented 9 years ago

+1

Same issue on Arch, uname -a:

Linux starship 4.0.7-2-ARCH #1 SMP PREEMPT Tue Jun 30 07:50:21 UTC 2015 x86_64 GNU/Linux

Gist with log output.

abargnesi commented 9 years ago

It seems that the zeromq library built with rbczmq is not available on the library path, so that the libzmq.so.3 shared library is never linked with rbczmq_ext.so.

Prepending LD_LIBRARY_PATH shows this to be true:

irb(main):001:0> require 'rbczmq'
LoadError: libzmq.so.3: cannot open shared object file: No such file or directory - /home/tony/.gem/ruby/2.2.0/extensions/x86_64-linux/2.2.0/rbczmq-1.7.8/rbczmq_ext.so
    from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/tony/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/lib/zmq.rb:9:in `rescue in <top (required)>'
    from /home/tony/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/lib/zmq.rb:6:in `<top (required)>'
    from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/tony/.gem/ruby/2.2.0/gems/rbczmq-1.7.8/lib/rbczmq.rb:3:in `<top (required)>'
    from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
    from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
    from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
    from (irb):1
    from /usr/bin/irb:11:in `<main>'

[tony@starship ruby]$ LD_LIBRARY_PATH=./2.2.0/gems/rbczmq-1.7.8/ext/rbczmq/dst/lib irb
irb(main):001:0> require 'rbczmq'
=> true
abargnesi commented 9 years ago

The above PR only addresses running rake from the project root as outlined in the README, but at least it matches the intention to use the vendored, compiled libraries.

Can we compute the destination of ext/rbczmq/dst/lib within the GEM PATH? If this is possible then we could set an absolute directory to where the vendored libzmq, czmq libraries will be installed.

methodmissing commented 9 years ago

Hi guys, merged the pull req. and shipped version 1.7.9. Thanks!