Re: vftable not found when __declspec(dllimport) used
BoHuang wrote:
Hi David
Can you elaborate on "pure abstract base class (interface), you do not
normally export classes"?
Indeed, I am now running into functions not found in DLL run time error
messages. I wonder if this is related. Please see my post "function not found
in DLL".
BoHuang:
Well, obviously, if the .exe does not know about the specific plugin at compile
time, it cannot import the specific class defined in each plugin.
The way to deal with this is to export two functions from each DLL:
PluginInterface* CreatePlugin();
and
void DestroyPlugin(PluginInterface* pPlugin);
These should be implemented (in the DLL) as
PluginInterface* CreatePlugin()
{
return new RTRTwrapper;
}
and
void DestroyPlugin(PluginInterface* pPlugin)
{
delete (RTRTwrapper*)pPlugin;
}
PluginInterface should be a pure interface with neither constructor or destructor.
The functions CreatePlugin() and DestroyPlugin() have the same names for each
plugin, and can be loaded from the .exe using LoadLibrary() and
GetProcAddress(). The client .exe does not know anything about the specific
class (e.g. RTRTwrapper) in each plugin DLL.
This method is essentially a simplified version of COM.
--
David Wilkinson
Visual C++ MVP