http://qs1969.pair.com?node_id=512500


in reply to Re: (tye)Re: programatically setting the LD_LIBRARY_PATH
in thread programatically setting the LD_LIBRARY_PATH

If you're doing this because a Perl module has a dependency on a native library (e.g. XML::LibXML), and you need to load the library from a non-default path (e.g. you have a version of libxml2 not in /lib or /usr/lib) and you want to avoid modifying LD_LIBRARY_PATH in a wrapper script or some kind of pseudo-wrapper like that shown above, there is another alternative. In the .bs file for the module, place a call to dl_load_file passing the absolute name of the native library. I used an environment variable to store my custom library path:
# Need to find libxml2. Cannot set LD_LIBRARY_PATH as it is already # cached by the linker. So we load libxml2 BEFORE loading # XML::LibXML's library. dl_load_file($ENV{FOO_PATH} . '/lib/os/libxml2.so.2');