# MDP - mdp_dlopen.h: Dynamic Library Loader

#### Mega Drive Plugins v1.0.0
Revision 0

MDP plugins are contained within dynamic libraries. To simplify the loading of MDP plugins in emulators, MDP provides a lightweight wrapper file, mdp_dlopen.h. This file contains macros that wrap around operating system functionality for loading dynamic libraries.

Operating systems currently supported with mdp_dlopen.h:

- Microsoft Windows 32-bit/64-bit
- POSIX-compliant operating systems that support dlopen(), e.g. Unix, Linux, MacOS X, FreeBSD

Wrapper macros provided by mdp_dlopen.h:

Function | Description
--- | ---
void* mdp_dlopen(const char* filename); | Opens a dynamic library. filename: Filename of the dynamic library to open. Returns a pointer to the library handle, or NULL on error.
void mdp_dlclose(void* handle); | Closes a dynamic library. handle: Library handle previously obtained with mdp_dlopen()
void* mdp_dlsym(void* handle, const char* symbol); | Retrieves the specified symbol from an open library. handle: Library handle previously obtained with mdp_dlopen(). symbol: Name of the symbol to retrieve. Returns a pointer to the symbol in the library, or NULL on error.
const char* mdp_dlerror(void); | Retrieves the last error message from the dynamic library loader. Returns a const char* string, which must be freed later.
void mdp_dlerror_str_free(const char* errstr); | Frees an error string obtained by mdp_dlerror(). errstr: String to free.

Note: mdp_dlopen.h is provided as a convenience. Emulators implementing MDP do not need to use this file in order to load plugins.