The factory pattern is well known for implementing a virtual constructor. We have a abstract framework and don't want to know the concrete implementation.
The shared objects/shared libraries are an operating system mechanism to share codes between processes. Further, with the dlopen(3)-Mechanism we can dynamicaly load, link and execute code from an shared object.
A abstract interface has to be defined. The concrete implementation is done in the shared object.
The caller code only knows about the abstract interface.
Thus, a user can choose the implementation, the library at run time and the library can easily replaced.
Constructors of global objects are assembled by the Compiler and linker to the function _init(). The dlopen(3) calls this function.
Thus the caller need a function
extern C set_factory(Abstract Factory *f);This function an be called by an global Constructor in the shared object.