I'm trying to build a DLL which will manage various configuration options for my project as a Singleton.
I followed the method proposed here in the chosen answer, as shown below:
IBuildConfiguration.h
#if defined(BUILD_CONFIGURATION_LIBRARY_EXPORT)
# define BUILD_CONFIGURATION_API __declspec(dllexport)
#else
# define BUILD_CONFIGURATION_API __declspec(dllimport)
#endif // BUILD_CONFIGURATION_LIBRARY_EXPORT
class IBuildConfiguration
{
public:
virtual int foo(void) = 0;
};
BUILD_CONFIGURATION_API IBuildConfiguration& Instance(void);
BuildConfiguration.h
class BuildConfiguration : public IBuildConfiguration
{
public:
BuildConfiguration();
~BuildConfiguration();
virtual int foo(void);
};
Edit: Forgot to include implementation of Instance()
BuildConfiguration.cpp
int BuildConfiguration::foo(void)
{
return 1; //just a silly example
}
IBuildConfiguration& Instance(void)
{
static BuildConfiguration instance;
return instance;
}
Now, in Visual C++ 6, I added to my project a dependency on this new DLL and I included the IBuildConfiguration header in my source as such:
SystemCtrl.cpp
#include "../../BuildConfiguration/IBuildConfiguration.h"
IBuildConfiguration buildConfig = Instance();
My DLL builds successfully, however the project that uses it does not.
Unfortunately, this results in the following error:
int __thiscall IBuildConfiguration::foo(void)' : pure virtual function was not defined
copying the DLL and LIB files into the project doesn't seem to solve the issue.