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

Configurable ROS2 initialization arguments and perhaps native subdirectory path library loading? #134

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ha-ves
Copy link

@ha-ves ha-ves commented Aug 3, 2024

This was simple,

  1. A better configuration for ROS2 initialization arguments,
  2. For Windows, to better organize the dynamic-linked ROS2 binaries in a subfolder in case of a tooling app.

So,

  • Followed ROS2 initialization by overloading Init() method for args,
  • Added Path combining in DllLoadUtils for subfolder with constant name. (& Absolute Path-ing)

You can choose not to include the library loading part, but the initialization part is better because if you're running the executable from CMD/PowerShell, the args[0] will be the executable path.

@ha-ves ha-ves marked this pull request as ready for review August 18, 2024 22:35
@@ -243,7 +249,7 @@ public class DllLoadUtilsWindowsDesktop : DllLoadUtilsAbs

public override IntPtr LoadLibrary(string fileName)
{
string libraryName = fileName + "_native.dll";
string libraryName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AssemblyDirectory, fileName + "_native.dll");
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO this is a bit of a patch.
The search path should not be set to a hard path, as you cannot change the path of the library now. it is better to use the "AddDllDirectory" function. https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-adddlldirectory.
This is also the recommended solution from microsoft in the LoadLibraryA function https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya

Copy link
Author

Choose a reason for hiding this comment

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

How about the UWP part? I haven't found any recommendation on loading from sub-directory in UWP.

Copy link
Contributor

Choose a reason for hiding this comment

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

seems like there is no "addDllDirectory" for UWP. but following the microsoft documentation it says that you need to add the path to the packagedepency in the application package manifest https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-loadpackagedlibrary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants