Embedding Runtime Search Path into Library on AIX

My product has 2 libraries say "x & y".
x depends on y.

During the installation of my products package, user will be prompted for his own location to copy my product libraries.
Installation will copy libraries "x & y" and create my product specific ENV variable say "MYPATH" pointing to User picked install location.

Here User doesn't want to set LIBPATH nor he want to create any softlinks in "/usr/lib or /lib".

Now I should make my library "x" find its dependent "y" in the environment where there is no LIBPATH set nor softlinks created in "/usr/lib or /lib".

On other UNIX platforms, there is a concept of $ORIGIN and i am successful using this on other Unix platforms.

Since there is no concept of $ORIGIN on AIX, trying out alternatives on AIX

My Scenario:
************

My package install creates ENV variable �MYPATH� pointing to the User picked installed location.
Let say, User selected /home/lib and install will set "MYPATH=/home/lib"

Now I thought of accessing this variable in the runtime search path (Either specifying using -L or �blibpath) while building my libraries (x & y).

For a particular library, runtime search path(dump -X32 -H) should be like
INDEX PATH
0 $MYPATH

I�ve tried specifying $MYPATH in the makefile using �-L or �blibpath� but as MYPATH is not available during build time, NULL value got replaced.

INDEX PATH
0

I want $MYPATH to be considered as is so that at runtime it gets replaced with its value.

Tried Escaping $ and also used quotes but no use.
ex: $$\(MYPATH\)

Can this be possible? If possible, then how?

-Srikrishna Erra.

Usually, the compiler has a -R option (your compiler may vary) to specify the run time $LD_LIBRARY_PATH replacement. This is not really for general use, as $LD_LIBRARY_PATH or whatever local ld() likes is preferred, see man pages, but it is needed for set-uid and set-gid applications, where the LD_LIBRARY_PATH is ignored for pretty obvious security reasons.

I am using XL C/C++ compiler on AIX.
And "-R" is available on SOLARIS. No such option for XL C/C++ for AIX.

Anyway -R or LD_RUN_PATH set a library search path at compile time that becomes hard-coded in the binary. It cannot evaluate a MYPATH at runtime.
I think you need to create a start wrapper at installation time that sets LD_LIBRARY_PATH - typically a shell wrapper that prepends the custom location to LD_LIBRARY_PATH. At the end the wrapper calls the binary, passing the command line arguments.

#!/bin/sh
installdir=/usr/local # to be patched
LD_LIBRARY_PATH=$installdir/lib
export LD_LIBRARY_PATH
exec $installdir/bin/binary "$@"

How about -Z: IBM Compilers

As I said, for prosaic situations use: $LD_LIBRARY_PATH

On old HPUX, it seems they fuse in the path of every dynamic, so you have to use chattr to strip them out for a user-local install.