jeudi 23 juillet 2015

Load class from shared library without header file

I have my_program which loads some shared libraries. Basicaly user can create one project and then that project can be executed with my_program. I want to load class from shared library. I've found this example: C++ Dynamic Shared Library on Linux

This example is great, but I have a problem. I don't have header file. So, is there any possible way to load class for which I don't have header file? I suppose there isn't. If I am not mistaken I don't think that there is a way to load header file dynamically?

If user write class Child : public Parent then in my main program I must replace MyClass (from that example that I provided) with Child. I know which methods are in Child class, becase I provide BaseParent class with pure virtual methods. So I would include BaseParent in my main program. But still I would need to know class name of this project.

What if I say that project class name must be always MY_PROJECT? Would that help? Then I would know that I must replace MyClass (from example above) with MY_PROJECT but wouldn't that trigger an error because main program wouldn't know nothing about class MY_PROJECT?

I'm open for any suggestions because I am literally stuck.

Aucun commentaire:

Enregistrer un commentaire