I am writing a C application that can be extended at runtime using modules / common objects / DLLs. These modules can use the APIs of an existing program, but can also provide new functions for use in later loadable modules, so there is a possibility that the modules will be dependent on each other.
My current Linux approach is for each module to define a function depend (), which returns a list of other module names on which it depends. That way, I can compile and link each module for myself, load the module using dlopen () RTLD_LAZY, first resolve its dependencies, and then fully load it with RTLD_GLOBAL. This works great and does exactly what I want. It also allows me to replace a module with another version without recompiling all other modules depending on it.
An actual problem occurs when porting to Windows. Firstly, I did not find a way to link the DLL without providing it with export symbol tables of all its dependencies. Is there one that I forgot?
Secondly, the LoadLibraryEx from the Windows API does not seem to be able to do any lazy loading, because instead of letting me handle the dependencies, it goes ahead and loads all the associated DLL files just before they return. Since I would also like to check the version before loading modules in the future, this is not at all what I want. Is there any way around this behavior?
The third feature is that I cannot replace the DLL without recompiling all other modules depending on it. Actually, this sometimes works, but usually wild things or a segfaults program happens.
Is it even possible to write such a modular application in Windows? Any suggestions or different approaches are highly appreciated!
: , Linux ( Windows): depend() , - . , Linux , .