Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust library search to work on windows, warn about lib prefix #97

Merged
merged 1 commit into from Jan 24, 2018

Conversation

wjwwood
Copy link
Member

@wjwwood wjwwood commented Jan 23, 2018

This is required for rviz to load .dll's on Windows which reside in bin. Also, all users are probably including the implicit lib prefix for their libraries explicitly, e.g.:

https://github.com/ros2/rviz/blob/4e10a6925d8db08e539ea54997abeb1ed6226767/rviz_default_plugins/plugins_description.xml#L1

This is not so portable because the cmake code uses <library_name> which generates a library like lib<library_name>.so on Linux and lib<library_name>.dylib on macOS, but <library_name>.dll on Windows.

So, I added the ability for pluginlib to search with and without the lib prefix, i.e. if you give libfoo it will also search for foo, and if you give foo it will also search for libfoo. However, giving slight preference to the user input without the lib prefix, I added a warning that prints if you give libfoo which suggests you use foo instead.

Long term, I think we should deprecate this searching and instead use compile time information to store the actual location (relative or absolute) of the library and simply match that with what is in the plugin description .xml by name.

@mikaelarguedas
Copy link
Member

Thanks @wjwwood, I'll have a look soon

@wjwwood
Copy link
Member Author

wjwwood commented Jan 23, 2018

Here's ROS 2 CI:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Copy link
Member

@mikaelarguedas mikaelarguedas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, thanks ! 👍

};

// Prepare to setup the relative file paths.
bool debug_library_suffix = (0 == class_loader::systemLibrarySuffix().compare(0, 1, "d"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that currently systemLibrarySuffix will always return the non debug version (but that's great to keep logic for handling both)

const char * lib_prefix = "lib";
if (library_name.rfind(lib_prefix, 0) == 0) {
library_name_alternative = library_name.substr(strlen(lib_prefix));
RCUTILS_LOG_WARN_NAMED("pluginlib.ClassLoader",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for adding the warning that'll help converge to the new way of defining them

@wjwwood
Copy link
Member Author

wjwwood commented Jan 24, 2018

Thanks for the quick review @mikaelarguedas 👍

@wjwwood wjwwood merged commit b456beb into ros2 Jan 24, 2018
@wjwwood wjwwood deleted the fix_searching_for_libraries_on_windows branch January 24, 2018 04:05
wjwwood added a commit that referenced this pull request Feb 8, 2018
* remove references to plugin_tool from CMakeLists (#93)

* move pluginlib in its own folder (port 83 to ros2 branch) (#95)

* move pluginlib in its own folder (port 83 to ros2 branch)

* fix most linter errors

* forward port of #88

Continue loading classes on error

* vs2015 doesnt support __has_include, VS2015 and 2017 have both <files… (#96)

* windows contains older version of std filesystem

* either <experimental/filesystem> or <filesystem> will work ... use experimental to be namespace-consistent

* vs2015 doesnt support __has_include, VS2015 and 2017 have both <filesystem> and <experimental/filesystem> but use std::experimental::filesystem in both cases

* adjust library search to work on windows, warn about lib prefix (#97)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants