Quick question regarding abstract classes and DLLs
Hello,
I have a rather simple question which I can't solve on my own because I'm still a rookie :)
Anyway, I have my main application (main.exe) and a module.dll. My application has an AbstractModule class for custom modules and the module.dll uses this.
AbstractModule.h
Code:
//.h
class AbstractModule
{
public:
bool isSomething() const;
};
//.cpp
bool AbstractModule::isSomething()
{
return true;
}
Now I create a separate module dll for the first module ("module.dll") and it uses the "abstractmodule.h":
Code:
//.h
#include <abstractmodule.h>
class Module : public AbstractModule
{
public:
Module();
};
//.cpp
Module::Module()
{
bool isIt = this->isSomething(); //Link error (LNK2019)
}
{
return "Test";
}
In Visual Studio I set the "module.dll"-project to be dependent on the "main.exe"-project.
But when I try to compile the solution I get a link error:
Quote:
error LNK2019: unresolved external symbol [...]
I guess it has somehow to do with the fact that the definition of AbstractModule::isSomething() is in the .exe?
I'm sorry, but I'm totally new to this whole dll stuff :)
Thank you for your help.
Re: Quick question regarding abstract classes and DLLs
If the abstract module has at least one method actually implemented, you have to add the definition to the dll as well, you can't make a dll depend on an exe (only the other way round).
Hint: You can define some methods in the header file, so you don't have to add any cpp files to your library.