I need a Cross-Platform, easy to use plugin library.
It needs to be able to load share libraries for Windows (.dll) and Linux (.so I think). The only one I could find was DynObj, but I can't figure out how it works. The compiler I'm using is MinGW.
If any one has used DynObj or another plugin library, I would greatly appreciate an explination on how the library and plugins work.
It's easy, across platforms even, to implement your own (although I wouldn't recommend it for use, just as a learning exercise). Each platform provides a similar APIs with possible extended feature for their own implementation of the shared library. For instance, a Windows DLL API adds functionality to treat a DLL as an executable. The POSIX API does not (and the general consensus is that it's silly). However, a Linux shared library can still be used as an executable if so desired, it's just not expected by the POSIX API (example of this is to execute "/usr/lib/libc-<version>.so". It will provide information on extensions and such).
Basically, it's like this:
1. Open DLL/SO, given various parameters.
POSIX uses dlopen(), generally with (RTDL_NOW | RTDL_LOCAL): http://pubs.opengroup.org/onlinepubs/000095399/functions/dlopen.html
Windows uses LoadLibrary(), it provides sane defaults: http://msdn.microsoft.com/en-us/library/ms684179(v=vs.85).ASPX
2. Query a function handle name. It is queried by symbol name as that's how its identified in the shared library.
Windows uses FreeLibrary() http://msdn.microsoft.com/en-us/library/ms683152(v=vs.85).aspx
Notes:
There are various libraries that provide functionality for this already. Boost has a plugin library in sandbox. SDL has one in its core library. GLFW has one for OpenGL although it can be used for anything. Almost every utility library provides one... just understand that one generally does not have extra functionality over the other because of how easy and simple the concept of shared library loading is.
I have a few more questions; can I load classes from shared libraries, does dlopen() work on Angstrom (The default Linux OS for BeagleBones), and what exactly is POSIX?