LD_LIBRARY_PATH annoyances

Hey, mais on n’a pas besoin de ld_library_path ?

pourtant j’avais codé un élégant script :

#reorder front path items matching ie(PATH,/opt:/usr:/sbin:/bin) R_PATH

reorderpath()
{
A_PATH=$1
P_BEFORES=$2
A_PATH=`echo "$A_PATH"|sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'`
if [ "$A_PATH" = "" ];then return;fi
if [ "$P_BEFORES" = "" ];then return;fi
for P_BEFORE in `echo $P_BEFORES|sed -e 's/:/ /g'`;do
R_PATH=""
for I_PATH in `echo $A_PATH|sed -e 's/:/ /g'`;do
J_PATH=`echo $I_PATH|sed -e "s:^$P_BEFORE::"`
if [ "$I_PATH" = "$J_PATH" ];then
R_PATH="$R_PATH:$I_PATH"
else
R_PATH="$I_PATH:$R_PATH"
fi
done
R_PATH=`echo "$R_PATH"|sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'`
A_PATH=$R_PATH
done
}

mais sur AIX, impossible de concilier chef-solo et rpm

reorderpath $LD_LIBRARY_PATH /usr:/lib:/opt/freeware

ça met rpm en premier, rpm marche, mais pas chef-solo qui prend les libs (zlib) de /lib au lieu de /opt/chef/embedded ;

vice versa, rpm a besoin des libs zlib de /lib ;

et comme rpm est lancé par chef, ils devraient partager le même LD_LIBRARY_PATH.

je croyais ça insolube, eh ben non :

dans les fichiers compilés, il y a en dur la localisation de la lib.

Why LD_LIBRARY_PATH is bad says :

  1. Never ever set LD_LIBRARY_PATH globally.
  2. If you must ship binaries that use shared libraries and want to allow your clients to install the program outside a ‘standard’ location, do one of the following:
    • Ship your binaries as .o files, and as part of the install process relink them with the correct installation library path. (like oracle..)
    • Ship executables with a very long “dummy” run-time library path, and as part of the install process use a binary editor to substitute the correct install library path in the executable. (whaou, hacky!+1!)
  3. If you are forced to set LD_LIBRARY_PATH, do so only as part of a wrapper.

 

so (redhat/solaris/aix):

unset LD_LIBRARY_PATH LD_RUN_PATH LIBPATH

 

Pocket