1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
From: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date: Sun, 12 Jun 2022 18:28:23 +0200
Subject: Add default plugin path
ld.so/libdl will expand ${LIB} at runtime to the token that was
configured into our glibc, which in Debian's case is
"lib/x86_64-linux-gnu" or similar.
https://lists.debian.org/debian-python/2022/06/msg00052.html
---
pluginlib/include/pluginlib/class_loader_imp.hpp | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/pluginlib/include/pluginlib/class_loader_imp.hpp b/pluginlib/include/pluginlib/class_loader_imp.hpp
index 9538770..9a1a92b 100644
--- a/pluginlib/include/pluginlib/class_loader_imp.hpp
+++ b/pluginlib/include/pluginlib/class_loader_imp.hpp
@@ -551,6 +551,30 @@ std::string ClassLoader<T>::getClassLibraryPath(const std::string & lookup_name)
return *path_it;
}
}
+
+ // ${LIB} is resolved by dlopen
+ std::string default_path("/usr/${LIB}/ros/" + library_name + ".so");
+ try {
+ lowlevel_class_loader_.loadLibrary(default_path);
+ lowlevel_class_loader_.unloadLibrary(default_path);
+ return default_path;
+ } catch (const class_loader::LibraryLoadException & ex) {
+ RCUTILS_LOG_DEBUG_NAMED("pluginlib.ClassLoader",
+ "plugin not found in default path: %s",
+ default_path.c_str());
+ }
+
+ std::string alt_path("/usr/${LIB}/" + library_name + ".so");
+ try {
+ lowlevel_class_loader_.loadLibrary(alt_path);
+ lowlevel_class_loader_.unloadLibrary(alt_path);
+ return alt_path;
+ } catch (const class_loader::LibraryLoadException & ex) {
+ RCUTILS_LOG_DEBUG_NAMED("pluginlib.ClassLoader",
+ "plugin not found in default path: %s",
+ alt_path.c_str());
+ }
+
std::ostringstream error_msg;
error_msg << "Could not find library corresponding to plugin " << lookup_name <<
". Make sure that the library '" << library_name << "' actually exists.";
|