2
votes

This is the first time I have attempted to create a .dll, that will be used as a plugin to a 3rd party app.

I created a .dll project in VS210...New Project -> Win32 Console Application -> .dll + Empty Project options.

Then I added in the files I wanted to use and included the various include / dependency libs the code required. Furthermore, set the linker to include the output .lib

Configuration Properties -> Linker -> Advanced -> Import Library - $(OutDir)$(TargetName).lib

While the .lib is successfully compiled, as soon as VS tries to then build the .dll I get a load of "unresolved external symbol" errors relating to all the defined function names.

ClCompile:
SOMPlugin.cpp
Link:
Creating library F:\Data\My Documents\Visual Studio 2010\Projects\Plugin-SOM - Copy\Release\Plugin-SOM.lib and object F:\Data\My Documents\Visual Studio 2010\Projects\Plugin-SOM - Copy\Release\Plugin-SOM.exp
SOMPlugin.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall SOMPlugin::metaObject(void)const " (?metaObject@SOMPlugin@@UBEPBUQMetaObject@@XZ)
SOMPlugin.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall SOMPlugin::qt_metacast(char const *)" (?qt_metacast@SOMPlugin@@UAEPAXPBD@Z)
SOMPlugin.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall SOMPlugin::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@SOMPlugin@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
SOMPlugin.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall SOMPlugin::updateView(void)" (?updateView@SOMPlugin@@MAEXXZ)
SOMPlugin.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall SOMPlugin::updatedObject(int,class UpdateType const &)" (?updatedObject@SOMPlugin@@MAEXHABVUpdateType@@@Z)
SOMPlugin.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall SOMPlugin::addToolbox(class QString,class QWidget *)" (?addToolbox@SOMPlugin@@MAEXVQString@@PAVQWidget@@@Z)
SOMPlugin.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall SOMPlugin::log(class QString)" (?log@SOMPlugin@@MAEXVQString@@@Z)
SOMPlugin.obj : error LNK2001: unresolved external symbol "protected: virtual void __thiscall SOMPlugin::log(enum Logtype,class QString)" (?log@SOMPlugin@@MAEXW4Logtype@@VQString@@@Z)
SOMPlugin.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall SOMPlugin::~SOMPlugin(void)" (??1SOMPlugin@@UAE@XZ) referenced in function "public: virtual void * __thiscall SOMPlugin::`scalar deleting destructor'(unsigned int)" (??_GSOMPlugin@@UAEPAXI@Z)
SOMPlugin.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const SOMPlugin::staticMetaObject" (?staticMetaObject@SOMPlugin@@2UQMetaObject@@B)
F:\Data\My Documents\Visual Studio 2010\Projects\Plugin-SOM\Release\Plugin-SOM.dll : fatal error LNK1120: 9 unresolved externals

Any help would be much appreciated.

1
Need to see some code. :( Is this related to Qt somehow?karlphillip

1 Answers

3
votes

The lib will be generated even if you get linker errors. Let's look at one:

SOMPlugin.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall SOMPlugin::metaObject(void)const " (?metaObject@SOMPlugin@@UBEPBUQMetaObject@@XZ)

This is telling you that you haven't implemented the method SOMPlugin::metaObject(void)const. Have you?

The rest are similar, other than

SOMPlugin.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const SOMPlugin::staticMetaObject" (?staticMetaObject@SOMPlugin@@2UQMetaObject@@B)

In this case, you need a definition for the static member outside the class definition, in an implementation file.