How to build Qt 5.1.1 using Visual Studio 2012 for XP
There is nothing supernatural in this article. I just wanted to bring together all the nuances and problems that I encountered related to the construction of Qt in one article - suddenly it will come in handy for someone.
The task was primarily to get rid of problems with sound under XP, by using dsengine as an alternative to a self-made sound reproduction plugin (based on ffmpeg), and for Windows Vista + you can use wmfengine completely. Therefore, the choice fell on version 5.1.1.
I also aimed to get a more advanced version of the C ++ 11 language, so I built it under Visual C ++ 11.0 (x86). There are no problems with the x64 version of the libraries; it can be downloaded from the official site.
Also in the title of the article is “XP” - because it was on this operating system that problems arose.
So, let's get started ...
- At first, everything is simple - we look at the official website on the downloads page ( qt-project.org/downloads ) for the option that suits us or immediately download the sources ( download.qt-project.org/official_releases/qt/5.1/5.1.1/single ).
- Unpack further (the main thing in the way is better not to have spaces).
- Then we look for all the dependencies, read ( qt-project.org/wiki/Building_Qt_5_from_Git ) We understand
what we need:
- utilities from a folder in the root of the gnuwin32 archive
- Microsoft DirectX SDK (compilation of qt 5 requires the DirectX SDK - it should not be installed if there is Microsoft Visual C ++ 2010 x86 / x64 redistributable - 10.0. ( Number over 30319 ))
As a result, we get the following vars32.bat bat file :
REM For fast compiling set CL=/MP REM include set INCLUDE=e:\share\_open_source_\icu-51.2-vs2012\include\;e:\share\_open_source_\pthreads\include\;%INCLUDE% REM lib set LIB=e:\share\_open_source_\icu-51.2-vs2012\lib\;e:\share\_open_source_\pthreads\lib\x86\;%LIB% REM tools set PATH=e:\share\_open_source_\icu-51.2-vs2012\bin\;C:\Ruby200-x64\bin;%CD%\gnuwin32\bin\;C:\Python27;C:\Perl64\bin;C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Utilities\bin\x86;%CD%\qtbase\bin\;e:\share\_open_source_\pthreads\dll\x86\;%PATH%
- For a successful build under XP
- read an article on msdn on how to compile ( blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx
- we check that we have Visual Studio with at least one update
- pay attention to a typo in the ways (v7.1A)
- don't forget about running the script for nmake utility with the parameter
- add vars32. bat :
… REM for nmake CALL "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86 REM for XP set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE% set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH% set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib;%LIB% set CL=/D_USING_V110_SDK71_;%CL%
- Since this may not be enough to modify the Qt configuration files:
a) The qtbase \ src \ corelib \ io \ qfilesystemengine_win.cpp file , line 574 , change to
# if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && _MSC_VER < 1700) || (defined(Q_CC_MSVC) && _MSC_VER >= 1700 && defined(_USING_V110_SDK71_))
Otherwise, due to the announced derektivy _USING_V110_SDK71_ soyurat fail
b) File qtbase \ qmake \ Makefile.win32
to AC CFLAGS_BARE added -DUNICODE -D_USING_V110_SDK71_
c) File qtbase \ mkspecs \ win32-msvc2012 \ the qmake.conf , variable QMAKE_CFLAGS:
QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t -D_USING_V110_SDK71_
, as well as QMAKE_LFLAGS_CONSOLE and QMAKE_LFLAGS_WINDOWS :
QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE,5.01 QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS,5.01
- Next, we need to configure Qt. To do this, we create conf32.bat and append the following line to it
configure -no-angle -mp -debug-and-release -no-audio-backend -opengl desktop -platform win32-msvc2012 -skip qtwebkit -skip qtwebkit-examples -skip qttranslations -icu -prefix "c:\dev\building_qt\bin\x86" -opensource -confirm-license -nomake tests -nomake examples
-no-angle - since my project uses OpenGL “directly”, I had problems with ANGLE (http://qt-project.org/wiki/Qt-5-on-Windows-ANGLE-and-OpenGL). If in short, as I understand it, this is an additional abstraction over the OpenGL API, that's why I had problems with entities of the same name.
- -mp - same as CL = / MP - for faster compilation
- -no-audio-backend - no oncoming wmf media service
- -opengl desktop - compile with opengl support for desktop applications
- -skip qtwebkit and -skip qtwebkit-examples - do not spoil your mood collect them later, this is a developers flaw
- -skip qttranslations - I ruled out because if you take the icu version of version 50 then lrelease.exe will throw an error. This module, in my opinion, is not so important; therefore, we will also assemble it, but then.
- -prefix "c: \ dev \ building_qt \ bin \ x86" - the path to the built libraries
- -nomake tests -nomake examples - exclude and save time (even on my working computer, assembly without webkit takes 30 minutes)
- I also recommend using jom (http://qt-project.org/wiki/jom). A small utility that distributes nmake work to threads, the number of which equals the number of cores. For example, I have i7 with supposedly 8 cores - accordingly there will be 8 threads
- You can write it in the paths and use the convenient editor of environment variables repidee ( www.rapidee.com/ru/about ). Do not forget to restart the command line so that the changes take effect
- And so the assembly. Run cmd.exe in the root folder of the unpacked archive and type:
vars32.bat && conf32.bat
We make sure that we have Qt configured as we need
- We continue. We drive in:
if without webkit'a
jom && jom install
if all at once (and go to sleep)
jom && jom install && cd qttranslations && qmake && jom install && cd ..\qtwebkit && qmake && jom && jom install
- We start qmake (from qtbase / bin) to configure some module and get a makefile for nmake. So you can, for example, download an additional module to configure and assemble.
- For qttranslations do not forget about icu version 51. I can also notice that Qt applications may crash for this reason. To check icu's correct operation, for example, you can try calling QTextCodec :: codecForName (“CP1251”) , if the codec was able to get, then everything is fine.
- I had to finish qtwebkit / bridge api - passing QtRuntimeObject parameters from JS to C ++ does not work, and apparently for a long time.
- If the application does not start under XP, then you need to look at the dependencies through depends (http://www.dependencywalker.com/). Most likely they forgot about msvcp110.dll and msvcr110.dll .
Thanks for attention! I hope someone comes in handy. My application works great.