Help needed: weird native libs dependency issue (calling system fixes this)

Hello,

I’m facing something that I just don’t understand. I rely on a Java
library
(ARS) that uses JNI and native dll.

If I set LD_LIBRARY_PATH then call system(“jruby -S rake my-task”) from
my
Rakefile, for instance while running specs, the library works as
expected.

When I’m out of the specs and start using the library directly from my
rake
task without spawning a new process, the library complains about missing
dependencies.

Have you got any idea about what could be happening ?

I really need to make this work without spawning a new process.

any even vague hint will be very welcome, I’m stuck here!

– Thibaut

On Wed, Mar 31, 2010 at 10:31 AM, Thibaut Barrère
[email protected] wrote:

dependencies.

Have you got any idea about what could be happening ?

I really need to make this work without spawning a new process.

any even vague hint will be very welcome, I’m stuck here!

Not sure – if you set java.library.path or LD_LIBRARY_PATH before
launching the initial Rake, I’m assuming all is fine?

If you don’t have control over that, you may need to just
java.lang.System.load() the library file directly, assuming there
aren’t a bunch of dependencies that need to be loaded as well.

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Nick,

Not sure – if you set java.library.path or LD_LIBRARY_PATH before

launching the initial Rake, I’m assuming all is fine?

After reading your mail, I restarted from an empty batch file. I was
already
setting LD_LIBRARY_PATH.

Turns out that what fixes my issue is to add LD_LIBRARY_PATH to PATH,
too,
I’m not sure why.

But apparently it’s fixed. Thanks a lot!

– Thibaut

On Thu, Apr 1, 2010 at 3:39 AM, Thibaut Barrère
[email protected] wrote:

Is there anyone able to shed some light on why this must be set before the
process ? (I suspect something happens at JRuby boot that take these values
into account, and that changing the values later on inside the process
doesn’t trigger the same code).

As well, if this is confirmed to be the right way to do it, this could be
added to the FAQ maybe ? (I can write something if you agree on this).

Please feel free:

http://wiki.jruby.org/FAQs

I think that PATH is required on Windows (to find .dll),
LD_LIBRARY_PATH on Unix (to find .so), and DYLD_LIBRARY_PATH on Mac
OSX (to find .bundle).

/Nick

launching the initial Rake, I’m assuming all is fine?

After reading your mail, I restarted from an empty batch file. I was
already setting LD_LIBRARY_PATH.
Turns out that what fixes my issue is to add LD_LIBRARY_PATH to PATH, too,
I’m not sure why.
But apparently it’s fixed. Thanks a lot!
– Thibaut


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

A follow-up on this with more notes, in case this helps someone else
later
on:

  • LD_LIBRARY_PATH must be set before the JRuby process is launched.
    Setting it inside, while it’s running, won’t work in my case.
  • LD_LIBRARY_PATH must be appended to PATH,too, otherwise it won’t work
    (in
    my case I have native windows dll that comes along the jars).
  • this PATH tweak must be done before the JRuby process is launched,
    too.

With this in mind, everything works here!

Is there anyone able to shed some light on why this must be set before
the
process ? (I suspect something happens at JRuby boot that take these
values
into account, and that changing the values later on inside the process
doesn’t trigger the same code).

As well, if this is confirmed to be the right way to do it, this could
be
added to the FAQ maybe ? (I can write something if you agree on this).

cheers,

– Thibaut

2010/3/31 Thibaut Barrère [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs