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
---
 include/pluginlib/class_loader_imp.hpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/pluginlib/class_loader_imp.hpp b/include/pluginlib/class_loader_imp.hpp
index 12557a2..d53b8b3 100644
--- a/include/pluginlib/class_loader_imp.hpp
+++ b/include/pluginlib/class_loader_imp.hpp
@@ -511,6 +511,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.";
