![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Load a shared library at runtime and find its symbols. More...
#include "nilorea/n_common.h"Go to the source code of this file.
Macros | |
| #define | N_MODULE_ERROR_MAX 512 |
| longest error text kept by n_module_error(), terminator included | |
Functions | |
| int | n_module_close (N_MODULE **module) |
| Close a library and free its handle. | |
| const char * | n_module_error (void) |
| What the system said about this thread's last failed call. | |
| const char * | n_module_extension (void) |
| The file extension shared libraries have on this platform. | |
| N_MODULE * | n_module_open (const char *path) |
| Open a shared library. | |
| void * | n_module_symbol (N_MODULE *module, const char *name) |
| Find a symbol in an opened library. | |
Load a shared library at runtime and find its symbols.
A plugin host, or a program that uses a driver only when one is installed, opens a library by path or name, looks up entry points by name, and closes it. POSIX does that with dlopen/dlsym/dlclose, Windows with LoadLibrary/GetProcAddress/FreeLibrary; this module is the one place that knows which, so a caller has no platform branch of its own.
Failure to open is not logged above LOG_DEBUG: a program probing for an optional library tries several names and expects most to be absent. What the system said about the last failure is kept per thread and returned by n_module_error().
On Linux with a glibc older than 2.34 the program must link -ldl; the library's Makefile adds it.
Definition in file n_module.h.