29 m_handle = LoadLibrary(file_name.c_str());
31 m_handle = dlopen((file_name).c_str(), RTLD_GLOBAL | RTLD_LAZY);
36 log_debug(
"core",
"loaded library '{}'", file_name);
37 m_file_name = file_name;
41 auto error_message = std::string(
"");
43 error_message =
"to be implemented for windows based operating systems.";
45 error_message = dlerror();
47 log_error(
"core",
"cannot load library '{}' (error: {}) -- did you properly link the plugin?", file_name, error_message);
55 log_error(
"core",
"library '{}' already unloaded", m_file_name);
59 if (FreeLibrary(m_handle) == 0)
61 log_debug(
"core",
"unloaded library '{}'", m_file_name);
66 if (dlclose(m_handle) == 0)
68 log_debug(
"core",
"unloaded library '{}'", m_file_name);
74 log_error(
"core",
"cannot unload library '{}'", m_file_name);
82 fptr = GetProcAddress(m_handle, function_name.c_str());
85 log_error(
"core",
"cannot load function '{}' from library '{}'", function_name, m_file_name);
90 fptr = (
lib_fn_ptr_t)dlsym(m_handle, function_name.c_str());
93 log_debug(
"core",
"cannot load function '{}' from library '{}'", function_name, m_file_name);
std::string get_file_name() const
bool load_library(const std::string &file_name)
lib_fn_ptr_t get_function(const std::string &function_name)
#define log_error(channel,...)
#define log_debug(channel,...)