From 09f85e4957d38aca1915d17a7007a1397f3a469b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sat, 20 Jan 2024 18:33:39 -0500 Subject: [PATCH] [dylib] Allow to specify a list of dylibs to load instead of just one --- src/ossia/detail/dylib_loader.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ossia/detail/dylib_loader.hpp b/src/ossia/detail/dylib_loader.hpp index 0391d27da26..9264bf5f323 100644 --- a/src/ossia/detail/dylib_loader.hpp +++ b/src/ossia/detail/dylib_loader.hpp @@ -21,6 +21,21 @@ class dylib_loader } } + explicit dylib_loader(std::vector sos) + { + if(sos.empty()) + throw std::runtime_error("No shared object specified"); + + for(const auto so : sos) + { + impl = dlopen(so.data(), RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); + if(impl) + return; + } + + throw std::runtime_error(fmt::format("{}: not found. ", sos[0])); + } + dylib_loader(const dylib_loader&) noexcept = delete; dylib_loader& operator=(const dylib_loader&) noexcept = delete; dylib_loader(dylib_loader&& other) noexcept