plugin.h:
#include "common.h"
#include <iostream>
class PLUGIN_API plugin : public common
{
public:
plugin();
void printPlugin();
};
common.h:
#ifdef PLUGIN
#define MAIN_API __declspec( dllimport )
#define PLUGIN_API __declspec( dllexport )
#else
#define MAIN_API
#endif
class MAIN_API common
{
public:
common();
void print();
};
plugin.cpp:
#include "plugin.h"
plugin::plugin()
{
}
void plugin::printPlugin()
{
std::cout << "Hello from plugin" << std::endl;
common::print();
}
Now... how can I compile this plugin into a DLL without getting linker errors about unresolved symbols common::common() and common::print() ?
Or is this impossible? do I _have_ to link with the import library containing the "common" class?
This is using the Visual Studio 2003 command line tools. (cl + link)
Error crap:
link /nologo /INCREMENTAL /dll /out:plugin.dll /implib:plugin.lib plugin.obj
Creating library plugin.lib and object plugin.exp
plugin.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) pu
blic: __thiscall common::common(void)" (__imp_??0common@@QAE@XZ) referenced in f
unction "public: __thiscall plugin::plugin(void)" (??0plugin@@QAE@XZ)
plugin.dll : fatal error LNK1120: 1 unresolved externals