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, needs relative rpath using '$ORIGIN' #43

Open ackalker opened 9 years ago

ackalker commented 9 years ago

This is not working with version 1.7.9 on Arch Linux x86_64, rbzmq installed as a dependency of iruby, which itself was installed user-local using $ gem install iruby.

Test:

$ LD_DEBUG=libs irb
[...snip libraries loaded during startup of irb itself...]
irb(main):001:0> require 'zmq'
     18609: find library=libzmq.so.3 [0]; searching
     18609:  search path=ext/rbczmq/dst/lib/tls/x86_64:ext/rbczmq/dst/lib/tls:ext/rbczmq/dst/lib/x86_64:ext/rbczmq/dst/lib      (RPATH from file /home/miki/.gem/ruby/2.2.0/extensions/x86_64-linux/2.2.0/rbczmq-1.7.9/rbczmq_ext.so)
     18609:   trying file=ext/rbczmq/dst/lib/tls/x86_64/libzmq.so.3
     18609:   trying file=ext/rbczmq/dst/lib/tls/libzmq.so.3
     18609:   trying file=ext/rbczmq/dst/lib/x86_64/libzmq.so.3
     18609:   trying file=ext/rbczmq/dst/lib/libzmq.so.3
     18609:  search cache=/etc/ld.so.cache
     18609:  search path=/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/x86_64:/usr/lib(system search path)
     18609:   trying file=/usr/lib/tls/x86_64/libzmq.so.3
     18609:   trying file=/usr/lib/tls/libzmq.so.3
     18609:   trying file=/usr/lib/x86_64/libzmq.so.3
     18609:   trying file=/usr/lib/libzmq.so.3
     18609:
LoadError: libzmq.so.3: cannot open shared object file: No such file or directory - /home/miki/.gem/ruby/2.2.0/extensions/x86_64-linux/2.2.0/rbczmq-1.7.9/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/miki/.gem/ruby/2.2.0/gems/rbczmq-1.7.9/lib/zmq.rb:9:in `rescue in <top (required)>'
    from /home/miki/.gem/ruby/2.2.0/gems/rbczmq-1.7.9/lib/zmq.rb:6: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>'
irb(main):002:0>

Please consider linking using -Wl,-R,'$ORIGIN/../path/to/libdir' (note single-quotes to protect it from the shell!) to resolve this. The $ORIGIN path specifies the directory path of one shared library relative to that of another.

Please have a look at the first answer to this SO question: http://stackoverflow.com/questions/3960641/how-to-link-to-shared-lib-from-shared-lib-with-relative-path .