error LNK2019: unresolved external symbol
-
Hi,
As a beginner I read Qt for Beginners. All works well until point 10 Subclassing QWidget. When I enter code and try to compile I get 'error LNK2019: unresolved external symbol "public: __thiscall Window::Window(class QWidget *)" (??0Window@@QAE@PAVQWidget@@@Z) referenced in function _main'.
How do I solve the error?
/Jonny -
Hi,
As a beginner I read Qt for Beginners. All works well until point 10 Subclassing QWidget. When I enter code and try to compile I get 'error LNK2019: unresolved external symbol "public: __thiscall Window::Window(class QWidget *)" (??0Window@@QAE@PAVQWidget@@@Z) referenced in function _main'.
How do I solve the error?
/JonnyHi,
js6033 said in error LNK2019: unresolved external symbol:
How do I solve the error?
It's basic C++ and has little to do with Qt. You need to provide a body for the class' constructor. You have provided only declaration and when the linker runs it can't find the symbol so it complains.
Kind regards.
-
Hi,
Which tutorial is it ?
-
Show us the code and compile/link command and we can tell ya what's wrong. :)
-
tutorial at https://wiki.qt.io/Qt_for_Beginners
down to point 10 Subclassing QWidget are the codes. -
tutorial at https://wiki.qt.io/Qt_for_Beginners
down to point 10 Subclassing QWidget are the codes.@js6033 said in error LNK2019: unresolved external symbol:
tutorial at https://wiki.qt.io/Qt_for_Beginners
down to point 10 Subclassing QWidget are the codes.Do you have:
Window::Window(QWidget *parent) : QWidget(parent) { // ... }
in your cpp file?
-
This was taken from that tutorial:
window.cpp #include "window.h" #include <QPushButton> Window::Window(QWidget *parent) : QWidget(parent) { // Set size of the window setFixedSize(100, 50); // Create and position the button m_button = new QPushButton("Hello World", this); m_button->setGeometry(10, 10, 80, 30); }
If you have that window.cpp file and the code is in it like that then you just didn't include it in your build.
Make sure that the window.cpp file is being built and linked to the main executable in your project.