Each of these classes are in separate dll modules:
class Base
{
public:
virtual void foo();
void bar();
};
class Derived : public Base
{
public:
// override Base::foo()
void foo();
};
In Other.cpp:
#include "Derived.h"
The module that contains Derived links with Base.lib (not shown are the export/import directives). The module that contains Other.cpp links with Derived.lib, but not Base.lib. Up to this point, everything works fine.
However, if I change Base::bar() to be virtual and do not make a change to Derived, then the linker complains when linking Other.dll:
Other.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Base::bar()" ...
The only solutions I have found is to override Base::bar() in Derived or to have Other.dll also link with Base.lib. Both solutions are not desired because they add client requirements when the server changes.
Any ideas on a better way to access/define the base class virtual methods in this scenario?