United States-English |
|
|
HP-UX Reference > Ddlsetlibpath(3C)HP-UX 11i Version 3: February 2007 |
|
NAMEdlsetlibpath() — set the dynamic search path used to locate shared libraries DESCRIPTIONdlsetlibpath() is one of a family of routines that give the user direct access to the dynamic linking facilities (using the -ldl option on the compiler or ld command line). dlsetlibpath() sets the dynamic search path used by dlopen(), dlopene(), and dlgetfileinfo() to locate shared libraries. libpath is the dynamic search path. It is a list of one or more path names separated by colons (:). When searching for a library, the dynamic loader uses search paths in the following default order:
(See dld.so(5) for additional information on search paths and options that can change the order described above.) Any combination of these paths may be disabled by setting flags to one or more of the following flag values OR'ed together. If the following value is set, the dynamic loader does not search the specified location:
Multiple search paths can be disabled by OR'ing individual flags: flags = RTLD_FLAG_DISABLE_STD_PATH | RTLD_FLAG_DISABLE_CWD_PATH A single search path can be enabled by setting flags to the complement of the flag value that disables that search path: flags = ~RTLD_FLAG_DISABLE_DYNAMIC_PATH EXAMPLESThe following example illustrates the use of dlsetlibpath() to set the dynamic search path and disable 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 VALUEIf successful, dlsetlibpath() returns 0, otherwise a non-0 value is returned. More detailed diagnostic information is available through dlerror() or dlerrno(). ERRORSIf dlsetlibpath() fails, a subsequent call to dlerrno() returns one of the following values:
SEE ALSOdlopen(3C), dlopene(3C), dlgetfileinfo(3C), dlerrno(3C), dlerror(3C), dld.so(5). Texts and Tutorials:
|
Printable version | ||
|