Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pluginlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ if(CATKIN_ENABLE_TESTING)

add_library(test_plugins EXCLUDE_FROM_ALL SHARED test/test_plugins.cpp)
target_link_libraries(test_plugins ${class_loader_LIBRARIES})
if(WIN32)
# On Windows, default library runtime output set to CATKIN_GLOBAL_BIN_DESTINATION,
# change it back to CATKIN_PACKAGE_LIB_DESTINATION to match the library path described in plugin description file
set_target_properties(test_plugins PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_LIB_DESTINATION})
endif()

catkin_add_gtest(${PROJECT_NAME}_utest test/utest.cpp)
if(TARGET ${PROJECT_NAME}_utest)
Expand Down
6 changes: 6 additions & 0 deletions pluginlib/include/pluginlib/class_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ class ClassLoader : public ClassLoaderBase
const std::string & library_name,
const std::string & exporting_package_name);

#ifdef _WIN32
std::string getClassLibraryPathFromLibraryName(
const std::string & library_name,
const std::string & package_name);
#endif

/// Return the paths where libraries are installed according to the Catkin build system.
std::vector<std::string> getCatkinLibraryPaths();

Expand Down
36 changes: 35 additions & 1 deletion pluginlib/include/pluginlib/class_loader_imp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,42 @@ std::string ClassLoader<T>::getClassLibraryPath(const std::string & lookup_name)
ROS_DEBUG_NAMED("pluginlib.ClassLoader", "Class %s maps to library %s in classes_available_.",
lookup_name.c_str(), library_name.c_str());

std::string library_path = getClassLibraryPathFromLibraryName(library_name, it->second.package_);

#ifdef _WIN32
// Windows does not add 'lib' prefix to libary name, remove the prefix and try again
if ("" == library_path) {
std::string only_path;
std::string only_file;
size_t c = library_name.find_last_of(getPathSeparator());
if (std::string::npos == c) {
only_path = "";
only_file = library_name;
} else {
only_path = library_name.substr(0, c + 1);
only_file = library_name.substr(c + 1, library_name.size());
}

const std::string lib_suffix = "lib";
if (boost::starts_with(only_file, lib_suffix)) {
only_file = only_file.substr(lib_suffix.length());
if (!only_file.empty()) {
const std::string new_library_name = only_path + only_file;
library_path = getClassLibraryPathFromLibraryName(new_library_name, it->second.package_);
}
}
}
#endif

return library_path;
}

template<class T>
std::string ClassLoader<T>::getClassLibraryPathFromLibraryName(const std::string & library_name, const std::string & package_name)
/***************************************************************************/
{
std::vector<std::string> paths_to_try =
getAllLibraryPathsToTry(library_name, it->second.package_);
getAllLibraryPathsToTry(library_name, package_name);

ROS_DEBUG_NAMED("pluginlib.ClassLoader",
"Iterating through all possible paths where %s could be located...",
Expand Down