48#if LASS_PLATFORM_TYPE == LASS_PLATFORM_TYPE_WIN32
57DynamicLibrary::DynamicLibrary(
const std::string& path):
60 pimpl_ = ::LoadLibrary(path.c_str());
61 if (pimpl_ == NULL && !stde::ends_with(path,
".dll") && !stde::ends_with(path,
".pyd"))
63 pimpl_ = ::LoadLibrary( (path +
".dll").c_str() );
66 pimpl_ = ::LoadLibrary( (path +
".pyd").c_str() );
71 LASS_THROW_EX(DynamicLibraryError,
"Unable to load '" << path <<
"': " << impl::lass_FormatMessage(impl::lass_GetLastError()));
75DynamicLibrary::~DynamicLibrary()
78 ::FreeLibrary(
static_cast<HMODULE
>(pimpl_));
81DynamicLibrary::TFunctionPtr DynamicLibrary::resolveFunctionImpl(
const std::string& functionName)
const
84 TFunctionPtr fun = TFunctionPtr(::GetProcAddress(
static_cast<HMODULE
>(pimpl_), functionName.c_str()));
87 LASS_THROW_EX(DynamicLibraryError,
"Unable to resolve '" << functionName <<
"': " << impl::lass_FormatMessage(impl::lass_GetLastError()));
104DynamicLibrary::DynamicLibrary(
const std::string& path):
107 const int flags = RTLD_NOW | RTLD_GLOBAL;
108 pimpl_ = ::dlopen(path.c_str(), flags);
109 if (pimpl_ == NULL && !stde::ends_with(path,
".so"))
111 pimpl_ = ::dlopen( (path +
".so").c_str(), flags );
115 const char* msg = ::dlerror();
118 LASS_THROW_EX(DynamicLibraryError, msg);
122 LASS_THROW_EX(DynamicLibraryError,
"Unable to load " << path);
127DynamicLibrary::~DynamicLibrary()
133DynamicLibrary::TFunctionPtr DynamicLibrary::resolveFunctionImpl(
const std::string& functionName)
const
136 TFunctionPtr fun = ::dlsym(pimpl_, functionName.c_str());
139 const char* msg = ::dlerror();
142 LASS_THROW_EX(DynamicLibraryError, msg);
146 LASS_THROW_EX(DynamicLibraryError,
"Unable to resolve " << functionName);
157# pragma LASS_NOTE("no implementation for DynamicLibraryError, it will be unavailable.")
general utility, debug facilities, ...
Library for Assembled Shared Sources.