I am sure that this problem has been resolved before, and I am curious how this is done. I have a code in which at startup I want to scan the contents of a directory and load the functionality.
In particular, I work with a scripting engine that I want to be able to add function calls. I want the main engine to provide very limited functionality. The user should be able to add additional functions through third-party libraries, which I want the engine to scan and load. How it's done?
It depends on the platform. On win32, you call the LoadLibraryDLL to load, and then you get functions from it with GetProcAddress. On Unixy platforms, the equivalents are: dlopenand dlsym.
LoadLibrary
GetProcAddress
dlopen
dlsym
You can use the POSIX functions dlopen / dlsym / dlerror / dlclose on Linux / UNIX to dynamically open shared libraries and access the symbols (including functions) that they provide, see man for details.
If you want to use the library for this, I would recommend GLib (a utility library that is under the GTK + UI toolkit). It introduces the " " GModule ", which provides a clean, portable way to do this. It saves you from having to wrap the corresponding calls yourself, and also brings you the rest of GLib, which is very handy in C programs of any size.
Source: https://habr.com/ru/post/1698398/More articles:Elements with nowrap are bound to neighboring elements in WebKit - html.NET runtime hosting and window focus, problems and inconsistencies - .netwindsor lock: how to use type property as constructor in xml config? - castle-windsorException behavior in C # 2 delegates hosted in MS Excel and COM - c #How to work with Undocumented API / Framework under .NET? - c #Showing totals in a ListView LayoutTemplate - asp.netIncluding GqlQuery result set in python dictionary - python"Run As ..." incorrectly creating user environment - c #Silverlight 2 development using only Visual Studio? - visual-studio-2008how to get java app icon? - winapiAll Articles