29 #include <Pluma/DLibrary.hpp>
39 fprintf(stderr,
"Failed to load library: Empty path\n");
45 #ifdef PLUMA_SYS_WINDOWS
46 handle = ::LoadLibraryA(path.c_str());
48 fprintf(stderr,
"Failed to load library \"%s\".\n", path.c_str());
52 handle = ::dlopen(path.c_str(), RTLD_NOW);
54 const char* errorString = ::dlerror();
55 fprintf(stderr,
"Failed to load library \"%s\".", path.c_str());
56 if(errorString) fprintf(stderr,
" OS returned error: \"%s\".", errorString);
57 fprintf(stderr,
"\n");
69 #ifdef PLUMA_SYS_WINDOWS
70 ::FreeLibrary( (HMODULE)handle );
81 fprintf(stderr,
"Cannot inspect library symbols, library isn't loaded.\n");
85 #ifdef PLUMA_SYS_WINDOWS
86 res = (
void*)(::GetProcAddress((HMODULE)handle, symbol.c_str()));
88 res = (
void*)(::dlsym(handle, symbol.c_str()));
91 fprintf(stderr,
"Library symbol \"%s\" not found.\n", symbol.c_str());
99 DLibrary::DLibrary(
void* handle):
static DLibrary * load(const std::string &path)
Load a library.
Manages a Dynamic Linking Library.
void * getSymbol(const std::string &symbol)
Get a symbol from the library.