HP-UX Reference (11i v1 05/09) - 3 Library Functions A-M (vol 6)
d
dlopen(3C) dlopen(3C)
void *handle;
struct dlopen_opts opts;
int status;
memset(&info, 0, sizeof(info));
memset(&opts, 0, sizeof(opts));
/* Get file info */
status = dlgetfileinfo("libfoo.so", sizeof(info), &info);
opts.flags = RTLD_EXT_DATA_ADDR;
/* allocate memory for the data segment */
opts.data_addr = (char*) mmap(0, info.data_size,
PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_ANONYMOUS,
-1, 0);
/* call dlopene */
handle = dlopene("libfoo.so", RTLD_NOW|RTLD_GLOBAL, &opts);
/* Insert user code to use library */
/* close library */
status = dlclose(handle);
/* free memory */
munmap(opts.data_addr, info.data_size);
}
WARNINGS
In 64-bit mode, the environment variable LD_LIBRARY_PATH
and SHLIB_PATH should contain a
colon-separated list of directories, in the same format as the
PATH variable (see sh(1)).
LD_LIBRARY_PATH and
SHLIB_PATH are ignored if the process’ real user id is different from its
effective user id or its real group id is different from its effective group id (see exec(2)).
In 64-bit mode, with the
+compat option specified, LD_LIBRARY_PATH
and +b embedded path are
ignored while searching for dependent libraries.
Use caution when building shared libraries with external library dependencies. Any library that contains
Thread Local Storage (TLS) should not be used as a dependency. If a dependent library contains TLS, and
it is not loaded during program startup (that is, not linked against the executable), the dynamic loader fails
to perform the operation.
SEE ALSO
cc(1), ld(1), sh(1), exec(2), dlclose(3C), dlerrno(3C), dlerror(3C), dlsym(3C), dlgetfileinfo(3C), dlsetlibpath(3C)
Texts an d Tu tor ials
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)
HP-UX 11i Version 1: September 2005 − 6 − Hewlett-Packard Company Section 3−−177