Re: How to set LD_LIBRARY_PATH
[email protected] (Marilyn Sander)
| Newsgroups | perl.dbi.users,perl.beginners |
|---|---|
| Message-ID | <[email protected]> |
On May 29, 2010, at 6:24 AM, Paul Johnson wrote: > On Fri, May 28, 2010 at 11:23:32AM -0700, Marilyn Sander wrote: > >> On May 28, 2010, at 9:33 AM, Paul Johnson wrote: >> >>> On Fri, May 28, 2010 at 06:14:38AM -0400, John Scoles wrote: >>> >>>> You will have to set those values before your modules load. >>>> >>>> So you should stick them in the BEGIN and that should work >>> >>> ... except where it doesn't, such as on Solaris for example. Here, >>> LD_LIBRARY_PATH (at least) really does need to be set before the >>> process >>> starts. You can do this by writing a shell wrapper, or re-execing >>> your >>> perl script if the value is not already set. > >> Have you considered doing a require instead of a use. With >> require, the >> loading is done at run time, and would be governed by the setting of >> LD_LIBRARY_PATH, at the time the require statement is executed. >> Just set >> LD_LIBRARY_PATH before doing the require. > > I'm afraid that you may have misunderstood what I wrote. There are > times when you really do need to set the variable before the process > starts. > I did not misunderstand what you wrote. My reasoning was that the thing being loaded is a shared object (.so file). The system loader (ld) has to be invoked for loading a shared object. That seems to me to require a separate process, with an environment stack inherited from the Perl process that invokes it. I was also assuming that setting an environment variable at run time would set the environment for the Perl process that is executing the Perl program. However, I did not test it. I will test it and see what happens. --Marilyn