32 flags = RTLD_NOW | RTLD_GLOBAL;
38 if (!unloadOnDestruct)
49 ARMARX_ERROR <<
"Error while unloading dynamic library: " << lastError;
59 "A library is already loaded. Call unload first and make sure that all references "
60 "to this library are deleted.");
64 if (libPath.is_relative() && !std::filesystem::exists(libPath))
66 std::string absolutePath;
70 libPath = absolutePath;
74 if (!std::filesystem::exists(libPath))
81 handle = dlopen(libPath.c_str(), flags);
88 const char* error = dlerror();
102 this->libPath = libPath;
113 bool result = dlclose(handle) == 0;
117 const char* error = dlerror();
143 return handle !=
nullptr;
149 this->unloadOnDestruct =
unload;
175 std::filesystem::path
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
~DynamicLibrary() override
void setUnloadOnDestruct(bool unload)
std::string getErrorMessage() noexcept
std::filesystem::path getLibraryFilename() noexcept
void unload()
Unloads library.
void load(std::filesystem::path libPath)
Loads a shared library from the specified path.
bool isLibraryLoaded() noexcept
Checks if a library is currently loaded.
void setFlags(int newFlags)
Sets the shared library opening flags and reloads the library, if a library is already loaded.
static std::string GetSharedLibraryFileExtension()
void reload()
Reloads the current library.
This exception is thrown if an invalid value was specified for a property.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
This file offers overloads of toIce() and fromIce() functions for STL container types.