LD_LIBRARY_PATH - how to set?

Joal Heagney joal at bigpond.net.au
Thu Mar 31 14:16:33 CEST 2005

Roman Yakovenko wrote:
> Thanks for help. But it is not exactly solution I am looking for. I
> would like to do it from python script. For example
> update_env() #<- this function will change LD_LIBRARY_PATH
> import extension_that_depends_on_shared_library
> Roman
> On Mar 31, 2005 9:35 AM, John Abel <john.abel at pa.press.net> wrote:
>>With Solaris 8+ you would use the command crle, with Linux
>>(RedHat/SuSE/Mandrake) you need to add the relevant directories
>>/etc/ld.so.conf and run ldconfig.  I've not got a Debian box to hand, so
>>I can't say if it matches, but that should give you a pointer.
> I think I should have permissions to do it. (more over users of my
> scripts should have permissions )

Yep. Unfortunatly if you don't have access to the /etc/ld.so.conf file, 
the only option left is your wrapper script idea. (By the way, have you 
actually tested to see if setting the LD_LIBRARY_PATH actually works? If 
not, you're really up the creek.)

If the script is in shell, you could use something like:

(Dotted lines denote start and end of script, not actual script content)
if ! echo ${LD_LIBRARY_PATH} | /bin/fgrep -q "/path/to/your/library" then
export LD_LIBRARY_PATH=$oldpath":/path/to/your/library"
<wrapped program> $*

This will check to see if your library path is in the LD_LIBRARY_PATH, 
set it if it's not, and then run your wrapped program, passing it the 
arguments that the wrapper script was called by.


More information about the Python-list mailing list