Embedding Runtime Search Path into Library on AIX

Login or Register to Reply

Thread Tools Search this Thread
# 1  
Old 10-15-2014
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

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.


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.

Last edited by erra_krishna; 10-15-2014 at 03:35 PM..
# 2  
Old 10-15-2014
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.
# 4  
Old 10-16-2014
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.
installdir=/usr/local # to be patched
exec $installdir/bin/binary "$@"

# 5  
Old 10-23-2014
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.
Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
AIX full path to socket library digioleg54 AIX 2 01-06-2018 05:58 PM
AIX runtime programming issue Pug UNIX for Advanced & Expert Users 5 02-23-2016 03:45 PM
Library/header path for ./configure yifangt Programming 4 03-26-2015 12:56 PM
C++ library path yifangt Programming 1 08-13-2014 09:38 PM
How to Check the what runtime package is applied on AIX OS meetmallela AIX 1 02-17-2012 02:32 AM
unix Library path variables. anilcliff Shell Programming and Scripting 5 06-28-2011 08:36 AM
library path in linux bbala UNIX for Advanced & Expert Users 3 12-26-2010 07:36 PM
Shared library versioning problem at runtime imagtek Programming 1 08-25-2009 04:03 PM
runtime libs accessed by application in AIX naren_chella AIX 1 05-17-2009 03:28 PM
Re:How to get the path during runtime? Nandagopal Solaris 1 02-09-2009 12:09 PM
How to get the path during runtime? Nandagopal Solaris 1 02-09-2009 11:06 AM
Plz Help me to find GNU C++ Runtime Library smartgupta Linux 2 09-22-2008 06:57 AM
Allocate memory for a shell script in Aix at runtime-urgent critical aixjadoo UNIX for Advanced & Expert Users 1 06-12-2008 09:44 AM
removing library path C3000 HP-UX 4 11-19-2007 08:17 AM
library path nucca UNIX for Dummies Questions & Answers 2 06-06-2001 02:03 PM