1
votes

I am trying to compile this simple qt application with Visual Studio express 2013 for Desktop:

#include <QApplication.h>
#include <QTextEdit.h>

int main(int argv, char **args)
{
    QApplication app(argv, args);

    QTextEdit textEdit;
    textEdit.show();

    return app.exec();
}

but when I compile I have this error :

Errore 1 error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: __thiscall QApplication::QApplication(int &,char * *,int)" (__imp_??0QApplication@@QAE@AAHPAPADH@Z) non risolto nella funzione _main C:\Users\Enrico\Documents\Visual Studio 2013\Projects\Progetto2\Progetto2\Origine.obj Progetto2

English:

Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QApplication::QApplication(int &,char * *,int)" (__imp_??0QApplication@@QAE@AAHPAPADH@Z) referenced in function _main C:\Users\Enrico\Documents\Visual Studio 2013\Projects\Progetto2\Progetto2\Origine.obj Progetto2

Thanks for everyone who helps me.

1
Probably you didn't add the relevant Qt static/import libraries to the linker optionsMatteo Italia
Further, your includes should read #include <QApplication> and #include <QTextEdit> without the ".h" extension.dhaumann

1 Answers

1
votes

The root cause is the Qt libraries like QtCore5.dll are not being linked. You can manually specify them by editing the Linker options to your project, but but the elegant way is to use the Qt Visual Studio Add-in to easily do a number of things such as create new Qt projects with the Qt libraries selected. This will resolve your link error. The add-in also adds debugger visualization for Qt types, ties in Qt Designer, and many other useful things for using Qt for within Visual Studio.

But add-ins are not supported in Visual Studio Express. Instead you must install Visual Studio 2013 Community. VS 2015 Community is now shipping also, but the Qt add-in hasn't been updated to work with it yet.