How does ruby load a shared library

Hi,
I created an c extension which is linked with another shared library named
libfoo.so.
When I use this extension in ruby script, it evoke an error message:
./demo.rb:3:in 'require': libfoo.so: cannot open shared object file: No such
file or directory

If I move libfoo.so to /usr/lib, it works.
Is ther any other ways to deal with such problem? As I don't want to put the
library into /usr/lib or set the LD_LIBRARY_PATH.
Thanks in advance!

huiliang wu wrote:

Hi,
I created an c extension which is linked with another shared library named
libfoo.so.
When I use this extension in ruby script, it evoke an error message:
./demo.rb:3:in 'require': libfoo.so: cannot open shared object file: No such
file or directory

If I move libfoo.so to /usr/lib, it works.
Is ther any other ways to deal with such problem? As I don't want to put the
library into /usr/lib or set the LD_LIBRARY_PATH.
Thanks in advance!

Check out ldconfig(8)

Hi,

At Fri, 16 Jun 2006 16:58:09 +0900,
huiliang wu wrote in [ruby-talk:197609]:

Is ther any other ways to deal with such problem? As I don't want to put the
library into /usr/lib or set the LD_LIBRARY_PATH.

It very depends on what your platform is. Some systems have
-rpath option and/or LD_RUN_PATH environment variable for ld.

···

--
Nobu Nakada

If you're on GNU/Linux, maybe this article will help:
http://wiki.linuxquestions.org/wiki/Library-related_Commands_and_Files

---John

···

On 6/16/06, huiliang wu <huiliang.wu@gmail.com> wrote:

Hi,
I created an c extension which is linked with another shared library named
libfoo.so.
When I use this extension in ruby script, it evoke an error message:
./demo.rb:3:in 'require': libfoo.so: cannot open shared object file: No such
file or directory

If I move libfoo.so to /usr/lib, it works.
Is ther any other ways to deal with such problem? As I don't want to put the
library into /usr/lib or set the LD_LIBRARY_PATH.
Thanks in advance!

I set LD_LIBRARY_PATH using export LD_LIBRARY_PATH=/foo and it works.
Now I want to set environment variable in my ruby script, so I use
ENV['LD_LIBRARY_PATH'] = "/foo", but this time it doesn't work.
What's difference between using ENV in script and export in the linux shell?
Thanks in advance!

···

On 6/17/06, John Gabriele <jmg3000@gmail.com> wrote:

On 6/16/06, huiliang wu <huiliang.wu@gmail.com> wrote:
> Hi,
> I created an c extension which is linked with another shared library
named
> libfoo.so.
> When I use this extension in ruby script, it evoke an error message:
> ./demo.rb:3:in 'require': libfoo.so: cannot open shared object file: No
such
> file or directory
>
> If I move libfoo.so to /usr/lib, it works.
> Is ther any other ways to deal with such problem? As I don't want to put
the
> library into /usr/lib or set the LD_LIBRARY_PATH.
> Thanks in advance!
>

If you're on GNU/Linux, maybe this article will help:
Library - LQWiki

---John

The first time LD_LIBRARY_PATH is available to the linux dynamic
linker when it loads and links ruby, the second time not.

-Jürgen

···

On Mon, Jul 10, 2006 at 05:35:01PM +0900, huiliang wu wrote:

I set LD_LIBRARY_PATH using export LD_LIBRARY_PATH=/foo and it works.
Now I want to set environment variable in my ruby script, so I use
ENV['LD_LIBRARY_PATH'] = "/foo", but this time it doesn't work.
What's difference between using ENV in script and export in the linux shell?
Thanks in advance!

--
The box said it requires Windows 95 or better so I installed Linux