PDA

View Full Version : Compilation Error LNK2019



Afandi
20th December 2012, 07:39
I got this compilation error.

When I try to debug, I got these errors.

8519

main.obj:-1: error: LNK2019: unresolved external symbol "public: void __thiscall Keyboard::setWidget(class QWidget *)" (?setWidget@Keyboard@@QAEXPAVQWidget@@@Z) referenced in function _main

main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall Keyboard::Keyboard(class QObject *)" (??0Keyboard@@QAE@PAVQObject@@@Z) referenced in function _main

And the source come from this code.




Keyboard::Keyboard(QObject *parent) : QObject(parent)
{
theWidget = NULL;
}

void Keyboard::setWidget(QWidget* theWidget)
{
this->theWidget = theWidget;
}





I hope someone can tell me whether I got missing any things
or I need to change some things in the Build Setting.
Thank you

ChrisW67
20th December 2012, 10:45
Assuming that the Keyboard class is in a library, and the errors arise from trying to use it from outside the library, you need to ensure the library can be found in with entries in LIBS (see Declaring Other Libraries) and export the symbols (see Using Symbols from Shared Libraries)

amleto
20th December 2012, 14:58
thats a linker error, not a compiler error.

roumor
23rd December 2012, 15:14
hey i had the same problem. The code was compiling in Qt rc2 and threw unresolved externals when Qt 5 got released.
In RC2 I had set up compiler kit that was pointing towards my vs2010 because the default one didn't work. When Qt 5.0 got released my kit stopped working and the default one became functional instead. I don't know why because their settings were identical.

So if you did same try adding the default kit in your project settings. (button Projects on the left side of Creator and the AddKit button)