get the address of a symbol in a dynamically linked library
cc . . . -lc
void *dlsym(void *handle, const char *name);
allows a process to obtain the address of a symbol defined
within a shared object (dynamically linked library)
previously opened by
handle is a value returned by a call to
the corresponding shared object must not have been
name is the symbol's name as a character string.
searches for the named symbol in all shared
objects loaded automatically as a result of loading the
object referenced by
does not refer to a valid object opened by
or if the named symbol cannot be found within any of the
objects associated with handle,
More detailed diagnostic information is
The following example shows how
can be used
to access either function or data objects.
error checking has been omitted.
int i, *iptr;
/* open the needed object */
handle = dlopen("/usr/mydir/libx.so", RTLD_LAZY);
/* find address of function and data objects */
fptr = (int (*)(int))dlsym(handle, "some_function");
iptr = (int *)dlsym(handle, "int_object");
/* invoke function, passing value of integer as a parameter */
i = (*fptr)(*iptr);
is not part of any currently supported standard;
it is an extension of AT&T System V provided by
The Santa Cruz Operation, Inc.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003