Qt 5.6.0 configure with Visual Studio 2015
-
I am trying to configure Qt5.6.0 third party library in my visual studio.
I have set the all the environmental directories in visual studio. like below one.
Include directories - D:\5.6.0\WIN8664\include\QtCore D:\5.6.0\WIN8664\include\QtWidgets D:\5.6.0\WIN8664\include
Additional include directories - D:\5.6.0\WIN8664\include;
Linker - Additional library directories - D:\5.6.0\WIN8664\lib ;D:\5.6.0\WIN8664\plugins\platforms
Linker - Additional dependencies - Qt5Gui.lib;Qt5Core.lib
My code is snippet is like below one - C++ Empty project- source.cpp
#include <QApplication>
#include <QPushButton>int main(int argc, char **argv)
{
QApplication a(argc, argv);//QPushButton hello("Hello world!", 0);
//hello.resize(100, 30);
//
//a.setActiveWindow(&hello);
//
//////a.setMainWidget(&hello);
//hello.show();
return a.exec();
}While building above code in VS2015, it throws following errors-
1>------ Rebuild All started: Project: Test, Configuration: Debug x64 ------ 1> Source.cpp 1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl QApplication::QApplication(int &,char * *,int)" (_imp??0QApplication@@QEAA@AEAHPEAPEADH@Z) referenced in function main 1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl QApplication::~QApplication(void)" (_imp??1QApplication@@UEAA@XZ) referenced in function main 1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QApplication::exec(void)" (_imp?exec@QApplication@@SAHXZ) referenced in function main 1>E:\QT\Test\x64\Debug\Test.exe : fatal error LNK1120: 3 unresolved externals ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
-
QApplication and QPushButton are part of the widgets module so you also need to link to Qt5Widgets.lib.
-
On a separate note you can use the Qt Visual Studio Tools extension to facilitate the process