This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ibrary is executed. Either of these values can be or’d with the RTLD GLOBAL ﬂag.
#include <dlfcn.h> void *dlsym(void *handle, char *symbol);
returns: ptr to symbol if OK, NULL on error The dlsym function takes a handle to a previously opened shared library and a symbol name, and returns the address of the symbol, if it exists, or NULL otherwise.
#include <dlfcn.h> int dlclose (void *handle);
returns: 0 if OK, -1 on error The dlclose function unloads the shared library if no other shared libraries are still using it.
#include <dlfcn.h> const char *dlerror(void);
returns: error msg if previous call to dlopen, dlsym, or dlclose failed, NULL if previous call was OK The dlerror function returns a string describing the most recent error that occurred as a result of calling dlopen, dlsym, or dlclose, or NULL if no error occurred. Figure 7.16 shows how we would use this interface to dynamically link our libvector.so shared library (Figure 7.5), and then invoke its addvec routine. To compile the...
View Full Document