3 #if __has_include(<dlfcn.h>)
4 #include <ossia/detail/fmt.hpp>
15 explicit dylib_loader(
const char*
const so)
17 impl = dlopen(so, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE);
20 throw std::runtime_error(fmt::format(
"{}: not found. ", so));
24 explicit dylib_loader(std::vector<std::string_view> sos)
27 throw std::runtime_error(
"No shared object specified");
29 for(
const auto so : sos)
31 impl = dlopen(so.data(), RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE);
36 throw std::runtime_error(fmt::format(
"{}: not found. ", sos[0]));
39 dylib_loader(
const dylib_loader&) noexcept =
delete;
40 dylib_loader& operator=(
const dylib_loader&) noexcept =
delete;
41 dylib_loader(dylib_loader&& other) noexcept
47 dylib_loader& operator=(dylib_loader&& other) noexcept
63 T symbol(
const char*
const sym)
const noexcept
65 return (T)dlsym(impl, sym);
68 operator bool()
const {
return bool(impl); }