I’m sure this problem has been solved before and I’m curious how its done. I have code in which, when run, I want to scan the contents of a directory and load in functionality.
Specifically, I am working with a scripting engine that I want to be able to add function calls to. I want the core engine to provide very limited functionality. The user should be able to add additional functions through 3rd party libraries, which I want the engine to scan for and load. How is this done?
It depends on the platform. On win32, you call
LoadLibraryto load a DLL, then get functions from it withGetProcAddress. On Unixy platforms, the equivalents aredlopenanddlsym.