Qt LNK2019 Error with basic Qt5 application
I am trying to follow an online tutorial and learn Qt5 using QtCreator 2.6.1
However, I went and tried to write a basic application following this tutorial and I always get a linking error whenever I try to build a project:
#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello World");
label->show();
return app.exec();
}
As soon as I click "Build" I get about 50 errors that look something like this:
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QApplication::~QApplication(void)" (__imp_??1QApplication@@UAE@XZ) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (__imp_?exec@QApplication@@SAHXZ) referenced in function _main
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QWidget::show(void)" (__imp_?show@QWidget@@QAEXXZ) referenced in function _main
Is it possible to fix this by linking libraries etc. (assuming they are not linked correctly)? If not, is there something else I can do to try and fix this problem?
source to share
it is a linker error that cannot link object files together, remove everything first build directory
, then check that this line was added to your file .pro
:
QT += core gui widgets
this should work, if you get denied again, you should provide more information about your compiler and them search path
, and also post the content here .pro
.
source to share