Skip to content

Commit 203a3e7

Browse files
committed
Solve issue of dependencies in windows.
1 parent 20fba83 commit 203a3e7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

source/plugin/source/plugin_manager.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030

3131
#include <string.h>
3232

33+
#if defined(WIN32) || defined(_WIN32)
34+
#include <winbase.h>
35+
#endif
36+
3337
/* -- Declarations -- */
3438

3539
struct plugin_manager_iterate_cb_type
@@ -136,6 +140,15 @@ int plugin_manager_initialize(plugin_manager manager, const char *name, const ch
136140
}
137141
}
138142

143+
/* On Windows, pass the library path to the loader so it can find the dependencies of the plugins */
144+
/* For more information: https://github.com/metacall/core/issues/479 */
145+
#if defined(WIN32) || defined(_WIN32)
146+
if (SetDllDirectoryA(manager->library_path) == FALSE)
147+
{
148+
log_write("metacall", LOG_LEVEL_ERROR, "Failed to register the DLL directory %s; plugins with other dependant DLLs may fail to load", manager->library_path);
149+
}
150+
#endif
151+
139152
/* Initialize the plugin loader */
140153
if (manager->l == NULL)
141154
{

0 commit comments

Comments
 (0)