When developing a C/C++ (=2?) plugin based framework with shared objects/dynamic libraries that need to support live swapping what examples would be helpful to look at for implementation details?
Thanks.
Note: live swapping is the key point here, no need to restart the system is a requirement
Boost.Extension seems nice (never used it but will try soon). Another alternative would be the POCO SharedLibrary class.
If you are on POSIX,
dlopen()
,dlsym()
anddlclose()
are all you need.See
man dlsym
for details and examples.There is a good article about loading dynamic libraries, and plugin infrastructure is an example.
EDIT OP added Windows as requirement so this approach won't help since Windows isn't POSIX-compliant. However there are similar functions in WinAPI - see here.
You might want to try Boost.Extension but beware : despite its name, it is not one of boost libraries.
Here is a link to its documentation.
For C++ plugins you can check this article which detail how to achieve it with the previously mentionned posix calls.
Quoting the article :
If you want cross-platform library loading without having to develop for each platform's API individually, libltdl may help.
Boost.Extension seems to only support Windows PE
dll
s, UNIX ELF shared objects, and Mac OS X Mach-O bundles. Well, that may be sufficient for you...