in reply to ENV setting for library loading failure

LD_LIBRARY_PATH is set for the perl executable when the perl executable is started. You can set in in the perl script, but it is not going to impact the running program (e.g. perl itself). If the loader (ld.so in linux) does not know about a library when perl starts, changing the environment variable at runtime won't tell it). In other words, it's "too late". ld.so has already copied the LD_LIBRARY_PATH environment variable into is memory, started the program and left.
  • Comment on Re: ENV setting for library loading failure

Replies are listed 'Best First'.
Re^2: ENV setting for library loading failure
by mikeraz (Friar) on Jan 25, 2006 at 23:28 UTC

    So is there a work around? short of setting the environment and invoking a child copy of self? nevermind that doesn't work.

    Be Appropriate && Follow Your Curiosity
      Of course :-) If you are root on a linux machine (maybe others, dunno) you can use ldconfig to put the library directory into the system default path. You could make a shell wrapper for your script. You could make a C or other high-level language wrapper.

      I have not looked to see how to do binary plugins in perl. It can be done in C, so it can probably be done in perl. Binary plugins allow the application (perl) to link to a shared library defined at run time. I've done in in C, but there must be a perl way, Maybe someone with experience in that space can help you. In my experience it is not simple and the other techniques are likely easier to create and maintain.

        Oh, Duh, you do it (dynamic loading of DLLs)with DynaLoader if you have that. Silly me. But the other ways are still probably better. Time to go for a beer.

      Rebuild your perl so that it looks in /usr/local/lib (I believe something along the lines of -R/usr/local/lib to the link options).