Ruby and LD_RUN_PATH

  • Thread starter Lennon Day-Reynolds
  • Start date
L

Lennon Day-Reynolds

I'm trying to distribute a version of Ruby along with an application,
and have a dependency on several shared objects that need to be
distributed with it. On Windows, this is no problem: just add the DLLs
to the 'bin' directory from which Ruby is run, and the system picks
them up and loads them as needed.

Under Linux, though, I seem to be completely unable to get Ruby to
recognize the libraries. My file tree looks something like this:

app/
(my sources and data files go here)
ruby/
bin/
ruby
lib/
<somelib>.so
ruby/
1.8/
...

I'm setting LD_RUN_PATH to './ruby/lib', and then launching the Ruby
binary with the flags '-I./ruby/lib/ruby/1.8
-I./ruby/lib/ruby/1.8/i686-linux'. It finds the Ruby libraries and
shared object files just fine, but the <somelib>.so is not being
picked up.

Any ideas?
 
G

Gennady

Lennon said:
I'm trying to distribute a version of Ruby along with an application,
and have a dependency on several shared objects that need to be
distributed with it. On Windows, this is no problem: just add the DLLs
to the 'bin' directory from which Ruby is run, and the system picks
them up and loads them as needed.

Under Linux, though, I seem to be completely unable to get Ruby to
recognize the libraries. My file tree looks something like this:

app/
(my sources and data files go here)
ruby/
bin/
ruby
lib/
<somelib>.so
ruby/
1.8/
...

I'm setting LD_RUN_PATH to './ruby/lib', and then launching the Ruby
binary with the flags '-I./ruby/lib/ruby/1.8
-I./ruby/lib/ruby/1.8/i686-linux'. It finds the Ruby libraries and
shared object files just fine, but the <somelib>.so is not being
picked up.

Any ideas?

Try LD_LIBRARY_PATH

Gennady.
 
L

Lennon Day-Reynolds

Excellent. I've never really grokked the subtle distinctions between
LD_{LOAD,RUN,LIBRARY}_PATH env vars.

Thanks,
 
J

jim

* Lennon Day-Reynolds said:
I'm trying to distribute a version of Ruby along with an application,
and have a dependency on several shared objects that need to be
distributed with it. On Windows, this is no problem: just add the DLLs
to the 'bin' directory from which Ruby is run, and the system picks
them up and loads them as needed.

Under Linux, though, I seem to be completely unable to get Ruby to
recognize the libraries. My file tree looks something like this:

app/
(my sources and data files go here)
ruby/
bin/
ruby
lib/
<somelib>.so
ruby/
1.8/
...

I'm setting LD_RUN_PATH to './ruby/lib', and then launching the Ruby
binary with the flags '-I./ruby/lib/ruby/1.8
-I./ruby/lib/ruby/1.8/i686-linux'. It finds the Ruby libraries and
shared object files just fine, but the <somelib>.so is not being
picked up.

If you are launching your app with a shell wrapper script then
LD_LIBRARY_PATH is the way to go.

However, if you have a library that loads a .so file, and you don't
control the launching mechanism, then LD_RUN_PATH is what you need.

Now, you would think that you could set LD_LIBRARY_PATH within a
library before you require the lib.so, but this does not work.
Apparently ld does not re-read the environment (or, at least I
don't know how to get it to.)

However, you can set LD_RUN_PATH from the library, and your require
will work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top