HP-UX Reference (11i v2 07/12) - 3 Library Functions A-M (vol 6)

d
dlsetlibpath(3C) dlsetlibpath(3C)
EXAMPLES
The following example illustrates the use of dlsetlibpath()
to set the dynamic search path and dis-
able other search paths. For simplicity, error checking has been omitted.
#include <dlfcn.h>
int main() {
void *handle;
int status;
int flags;
/* Set dynamic search path and disable the embedded
* path and the standard library directory.
*/
flags = RTLD_FLAG_DISABLE_EMBEDDED_PATH |
RTLD_FLAG_DISABLE_STD_PATH;
status = dlsetlibpath("/opt/lib:/opt/usr/lib", flags);
/* Call dlopen to load a library using the dynamic
* search path.
*/
handle = dlopen("mylib.so", RTLD_LAZY);
/* Remove the dynamic search path and reenable all
* disabled search paths.
*/
status = dlsetlibpath(NULL, 0);
}
RETURN VALUE
If successful,
dlsetlibpath() returns
0, otherwise a non-0 value is returned. More detailed diagnostic
information is available through
dlerror() or dlerrno() .
ERRORS
If dlsetlibpath() fails, a subsequent call to
dlerrno() returns one of the following values:
[RTLD_ERR_NO_MEMORY] Cannot allocate dynamic memory.
[RTLD_ERR_CANT_APPLY_RELOC]
Failed to apply relocation while resolving call to
dlsetlibpath()
.
[RTLD_ERR_SIGINHIBIT_FAILED]
siginhibit call failed on entry to dlsetlibpath()
.
[RTLD_ERR_SIGENABLE_FAILED]
sigenable call failed on exit from dlsetlibpath()
.
[RTLD_ERR_SETCANCELSTATE_FAILED]
__thread_setcancelstate
failed on entry to or exit from
dlsetlibpath().
[RTLD_ERR_INV_DLSETLIBPATH_ARGUMENT]
Invalid argument in call to dlsetlibpath().
SEE ALSO
dlopen(3C), dlopene(3C), dlgetfileinfo(3C), dlerrno(3C), dlerror(3C), dld.so(5).
Texts and Tutorial s:
HP-UX Linker and Libraries Online User Guide
(See the +help option)
HP-UX Linker and Libraries User’s Guide
(See manuals(5) for ordering information)
326 Hewlett-Packard Company 2 HP-UX 11i Version 2: December 2007 Update