Question

Is there a way in D to load a dynamic library by specifying the exact file name and path? I want to implement a plugin system using dynamic libraries in a dedicated folder.

I am looking for something much like Runtime.loadLibrary(in char[] name) but instead of the name, it should take the full path.

Was it helpful?

Solution

Runtime.loadLibrary is implemented in terms of dlopen and LoadLibrary.

From dlopen's man page: "If filename contains a slash ("/"), then it is interpreted as a (relative or absolute) pathname."

From LoadLibrary's MSDN page: "If the string specifies a full path, the function searches only that path for the module."

So all you have to do is pass a full path to loadLibrary and it should just work (assuming loadLibrary works at all, tbh i'm not sure it is implemented fully in the current release).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top