If your native plugin needs additional libraries, the easiest thing for plugin developers is to statically link any needed library into their plugins. The next easiest thing is to create implicit dependencies to required dlls and make sure these dlls are stored in the same folder as your binary plugin.
In both cases, you have nothing special to do at runtime to load your libraries. If you must explicitly load dlls at runtime, you will need to take care also of any dependencies your dlls require. By default, the loader will not search in your plugin folder for dependent dlls. To ensure that, you need to:
GetDllDirectory()
SetDllDirectory()
to specify the folder you want to load from or the folder where the dependencies of the dll you want to load are locatedSetDllDirectory()
again to restore the previous valueNever call SetDllDirectory(nullptr)
, it adds the current working directory to the search path and causes a security vulnerability.
Always restore the dll directory to its original value. Not doing so can cause load issues for other plugins.