Operating System - HP-UX
1753482 Members
4293 Online
108794 Solutions
New Discussion

Re: Loading libraries from custom path

 
slash_blog
Occasional Advisor

Loading libraries from custom path

I am trying to build openldap using gcc. The build completes successfully. The problem is that library path is getting hardcoded.

 

So the following command works

 

$ ldd libraries/libldap/.libs/libldap.sl 
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /home/njakhar/njakhar/ovaldi/3rdParty/HP-UX/lib/libcrypto.sl.0.9.7 =>   /home/njakhar/njakhar/ovaldi/3rdParty/HP-UX/lib/libcrypto.sl.0.9.7
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /home/njakhar/njakhar/ovaldi/3rdParty/HP-UX/lib/libssl.sl.0.9.7 =>      /home/njakhar/njakhar/ovaldi/3rdParty/HP-UX/lib/libssl.sl.0.9.7
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /home/njakhar/njakhar/ovaldi/3rdParty-build/HP-UX/openldap-2.4.23/libraries/libldap/../../libraries/liblber/.libs/liblber-2.4.sl.7 =>   /home/njakhar/njakhar/ovaldi/3rdParty-build/HP-UX/openldap-2.4.23/libraries/libldap/../../libraries/liblber/.libs/liblber-2.4.sl.7
        /usr/lib/libc.2 =>      /usr/lib/libc.2

 

 

However, when I move /home/njakhar/njakhar/ovaldi/3rdParty/HP-UX/lib to current directory and set SHLIB_PATH to this new path ldd fails:

 

$ SHLIB_PATH=lib ldd libraries/libldap/.libs/libldap.sl 
        /usr/lib/libc.2 =>      /usr/lib/libc.2
        /usr/lib/libdld.2 =>    /usr/lib/libdld.2
        /usr/lib/libc.2 =>      /usr/lib/libc.2
/usr/lib/dld.sl: Can't find path for shared library: libcrypto.sl.0.9.7
/usr/lib/dld.sl: No such file or directory

 

How can I get around this?

 

PS: The build is already using -fPIC.

1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: Loading libraries from custom path

>The problem is that library path is getting hardcoded.

 

The linker provides several options:

-Wl,+s: enable SHLIB_PATH/LD_LIBRARY_PATH (for ELF files)

-Wl,+b: provide path in load module.

$ORIGIN: relative paths.

 

>set SHLIB_PATH to this new path ldd fails:

 

You need to use chatr(1) to see the path options.  You can also use "chatr +s enable" to enable SHLIB_PATH.