I’m using shared library with explicit linking (loading shared lib with dlopen) in order to implement plugin pattern in C++.
Is it possible to define a function pointer to a constructor of a class defined in the shared library or I would have to define factory method, within shared lib, that would instantiate (and initialize) object of a class from shared lib? Of course in my main app, then, I would define a function pointer to a factory method, and that method would return an instance of the class I need.
Cheers
The answer to the question is no, you can not define a member or function pointer to the constructor.
For dlopen, you need to provide a function with c linkage and load it dynamically, which you can use to create the objects, and you also need another function to delete objects.
More about it here