jeudi 24 mai 2018

boost runtime loading, runtime_symbol and alias

I am working with exported alias / runtime_symbols using boost to get a plugin based architecture, such that my application may load shared libs (that export types using the runtime_symbol approach in boost) during runtime and creates types from the dynamically loaded shared libraries.

I create a Main application executable.

I create one library LibA.so that exports a type A such that the Main application can load the LibA.so during runtime and create an instance of type A.

I create one library LibB.so that exports a type B, and I want the Main application to load this library during runtime and create instances of type B.

This works well, but if B needs to know about / acting on type A I run into problems. For example if type B has a shared_ptr < A > member, so libA.so has to link to libB.so, boost does not manage to load the libB.so anymore. It throws saying "Bad file descriptor" when trying to load libB.so

Is there any way to solve this problem?

I have realized that if I let type A inherit from a an abstract type ABase and I store ABase in its own shared library libABase.so, I could get it all working by linking the main application, libA.so and libB.so against libABase.so if I also make sure type B holds a shared_ptr < ABase > member instead of a shared_ptr < A > member. But I would prefer not having to work through an "interface" when accessing type A in libB.so.

Can this be resolved?

Aucun commentaire:

Enregistrer un commentaire