📜 ⬆️ ⬇️

How to build Qt 5.1.1 using Visual Studio 2012 under XP

Introduction

This article is nothing supernatural. I just wanted to bring together all the nuances and problems that I encountered, related to the construction of Qt in one article - all of a sudden someone will come in handy.

The task was primarily to get rid of problems with sound under XP, by using dsengine as an alternative to a self-written audio playback plug-in (based on ffmpeg), and for Windows Vista + you can fully use wmfengine. Therefore, the choice fell on version 5.1.1.
I was also aiming 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 library; it can be downloaded from the official website.
Also in the title of the article there is “XP” - because it was on this operating system that problems arose.

So let's get started ...

  1. At first, everything is simple - we search on the official website on the downloads page ( qt-project.org/downloads ) to find the right option for us or immediately download the source code ( download.qt-project.org/official_releases/qt/5.1/5.1.1/single ).
  2. Then unpack (the main thing in the way is better not to have any spaces).
  3. Further we look for all dependences, we read ( qt-project.org/wiki/Building_Qt_5_from_Git )
    We understand what we need:

    • icu
    • pthreads
    • Ruby
    • utilities from the folder in the gnuwin32 archive root
    • Microsoft DirectX SDK (for compiling qt 5 DirectX SDK is required - 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 bat-file vars32.bat :
    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% 

    ')
  4. For a successful build under XP
    • read the msdn article on how to compile ( blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx
    • check that we have Visual Studio has at least one update
    • pay attention to typo in the paths (v7.1A)
    • Do not forget about running the script for the utility nmake with the parameter
    • we finish 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 sufficiently modifying the Qt configuration files:
      a) File qtbase \ src \ corelib \ io \ qfilesystemengine_win.cpp , 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, because of the declared directive _USING_V110_SDK71_ , it will not succeed
      b) The qtbase \ qmake \ Makefile.win32 file
      in the variable CFLAGS_BARE add on -DUNICODE -D_USING_V110_SDK71_
      c) The qtbase \ mkspecs \ win32-msvc2012 \ qmake.conf file , to the QMAKE_CFLAGS variable:
       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 

  5. Next we need to configure Qt. To do this, we create conf32.bat and add 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 have problems with ANGLE (http://qt-project.org/wiki/Qt-5-on-Windows-ANGLE-and-OpenGL). In short, as I understood 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 - without wmf media service
    • -opengl desktop - build with opengl support for desktop applications
    • -skip qtwebkit and -skip qtwebkit-examples - don’t spoil your mood collect them later, this is a developer bug
    • -skip qttranslations - I excluded because if you take version icu version 50 then lrelease.exe will throw out an error. This module in my opinion is not so important, therefore, we will also collect, but then.
    • -prefix "c: \ dev \ building_qt \ bin \ x86" - path to the built libraries
    • -nomake tests -nomake examples - exclude and save time (even on my work computer, an assembly without a webkit takes 30 minutes)
  6. I also recommend using jom (http://qt-project.org/wiki/jom). A small utility that distributes nmake work to threads whose number equals the number of cores. For example, I have an i7 with ostensibly 8 cores - accordingly there will be 8 threads
  7. 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
  8. And so the assembly. Run cmd.exe in the root folder of the unpacked archive and type:
     vars32.bat && conf32.bat 

    Make sure that we have Qt configured as we need.
  9. 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 


    • Run 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 build.
    • For qttranslations, we don’t forget about icu version 51. I can also notice that Qt applications may fall for this reason. To check the correctness of icu operation, for example, you can try to call QTextCodec :: codecForName (“CP1251”) , if you managed to get the codec, all is well.
    • I had to finish qtwebkit / bridge api - the transfer of QtRuntimeObject parameters from JS to C ++ does not work, and apparently for a long time.
    • If the application does not run under XP, then you need to see the dependencies via depends (http://www.dependencywalker.com/). Most likely forgot about msvcp110.dll and msvcr110.dll .


Thanks for attention! I hope someone will come in handy. My application works great.

Source: https://habr.com/ru/post/200474/


All Articles