c++ - Inheritence over shared library boundaries -
i have 2 binaries, liba.so , exeb. liba exports many of it's functions, including few classes. consider following simplified example:
from liba.so:
#define export __attribute__((visibility("default"))) class export foo { public: export foo(); // implemented in cpp export virtual ~foo(); // implemented in cpp export virtual int func(int b); // implemented in cpp }; class export bar : public virtual foo { public: export bar(); // implemented in cpp export virtual ~bar(); //implemented in cpp export virtual char anotherfunc(char d); //implemented in cpp };
moving on executable b:
class baz : public bar { public: void usefuncandanotherfunc(); //implemented in cpp };
in baz.cpp:
foo *p = /* ... */; bar *q = dynamic_cast<bar *>( p ); // culprit
during compilation stage, greeted following error:
undefined reference `typeinfo foo' undefined reference `typeinfo bar'
even though i'm exporting functionality of classes, compiler still complains. virtual inheritence , virtual functions required because project, c, overrides them (unit testing). however, project c links against static library version of code , no errors given. seems apply *.so variants.
any ideas on how fix this?
Comments
Post a Comment