Happy New Year!
Digia offers Qt5 for Windows only copied under Visual Studio 2010, and with parameters that are not ideal for everyone. In particular this
- Actually, the very need to use only VS2010 and the dependency Visual C ++ 2010 Runtime (msvcr100.dll, msvcp100.dll)
- the dependence of Qt5Core.dll (and accordingly your application) on ICU . These are the following DLLs: icuin49.dll, icudt49.dll, icuuc49.dll
- Qt5Gui.dll dependency on Angle Library . These are the following DLLs - libEGL.dll, libGLESv2.dll
In the end, you will also consider the question of the subsequent distribution of applications without the need to install
Microsoft Visual C ++ 2008 Redistributable Package when installing your program.
What is necessary
Note: since I do not need to compile qtactiveqt, qtdeclarative, qtwebkit and others, but only qtbase is needed (Qt5Core / Qt5Gui / Qt5Network / Qt5Widgets / Qt5Sql / etc) and qttools (as an assistant, designer, etc), I will only run qtbols / etc) qttools, whereas when fully compiling the library, configure should be run at the root.
Note 2 : By default, qt5 tries to use OpenGL 2 / Angle, which requires the
DirectX SDK to compile. Since I do not need QML2 and OpenGL2, I use the
configure -opengl desktop option, which tells QtGui to use the old opengl32.dll (OpenGL 1.1 standard, available in any Windows XP and higher). For the experiment, I also compiled with the DirectX SDK installed, in this case there will be 2 additional DLLs in the Qt5Gui.dll dependencies - libEGL.dll and libGLESv2.dll.
')
Compilation
- Extract the qt-everywhere-opensource-src-5.3.0.tar.gz archive to a folder. In this example, this is C: \ qt
- Qt 5 has a nuance that prevents self-compilation. To solve it, comment out the line
if not exist %QTSRC%\.gitignore goto sconf
in qtbase \ configure.bat - Go to C: \ qt and create a file qt5vars.cmd with the following content:
CALL "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 set PATH=c:\qt\qtbase\bin;c:\qt\qtrepotools\bin;c:\qt\gnuwin32\bin;%PATH% set QMAKESPEC=win32-msvc2008 cd qtbase
Now in the same place we create a new label ( cmd.lnk ) with the following properties:
Object :% SystemRoot% \ system32 \ cmd.exe% SystemRoot% \ system32 \ cmd.exe / E: ON / V: ON /kc:\qt\qt5vars.cmd
Working folder : c: \ qt
- Run cmd.lnk and execute the following commands sequentially, between which you can drink coffee:
Build qtbase
configure -opengl desktop -no-plugin-manifests -mp -nomake tests -D "_BIND_TO_CURRENT_VCLIBS_VERSION=1" nmake
Note 1 I use -D "_BIND_TO_CURRENT_VCLIBS_VERSION = 1" always to avoid problems with different versions of run-time libraries installed on the computer (the studio can use for linking different from that used for Qt compilation). The same define is used in the projects themselves.
Remark 2 -no-plugin-manifests is used to prevent studio manifest from adding plugin files to DLL files (for correct application distribution without Visual C ++ Redistributable settings). This option should be the default, but this is an old bug .
Build qttools
cd ..\qttools qmake nmake nmake docs cd ..\qtbase nmake docs
Application distribution
A simple and convenient way to not require the installation of a Visual C ++ 2008 Redistrubutable package is to carry
3 files with you :
msvcp90.dll, msvcr90.dll and Microsoft.VC90.CRT.manifest
Here we consider a fairly simple example of an application that has been ported from Qt4 to Qt5. Previously, there were 3 Qt modules in its dependencies - QtCore4.dll, QtGui4.dll, QtNetwork4.dll. Now Qt-shny libraries 4 - Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll, Qt5Widgets.dll. However, besides this, you need to carry along with you one mandatory plugin - qtbase \ plugins \ platforms \ qwindows.dll, this is a consequence of the level of abstraction from the operating system in Qt5. It is loaded implicitly, so I did not immediately figure out why the application does not start on a clean machine. So I compiled the following list of what should be in the installer:
- myapp.exe
- Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll, Qt5Widgets.dll
- msvcp90.dll, msvcr90.dll, Microsoft.VC90.CRT.manifest
- platforms \ qwindows.dll
Having this set of files, you ensure your 100% runtime of your application everywhere and always.
PS For whom you need additional formats of graphic files or SQL drivers, as usual, you should also throw the corresponding DLLs into the imageformats or sqldrivers folders.