DLL plugin linking problems

Started by
1 comment, last by ldeej 18 years, 5 months ago
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
Advertisement
Quote:Original post by dotproduct
do I _have_ to link with the import library containing the "common" class?


Looks that way to me.

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Yes, you need common's implementation to be available, otherwise the linker will miss information about the common subobject on the plugin object.

This topic is closed to new replies.

Advertisement