2015年10月14日 星期三

Build Qt 5.5 in Windows: Use VS2010


     In this article, I would record how to build Qt 5.5. I use Qt 5.5.0 as my example here, but the procession mentioned below works for building Qt 5.5.1.

Step 0:
     Download Qt 5.5.0 and decompress it, I put that in folder C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0. Then set python develop environment(you could check my previous article to set it).

Step 1:
     As my previous article, the windows linking target should be changed from MSVCRT.lib to LIBCMT.lib, that makes the built Qt libraries be more portable.

   That's, change the lines in file C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0\qtbase\mkspecs\common\msvc-desktop.conf, from line number 32 :


QMAKE_CFLAGS_RELEASE    = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MTd

After Qt 5.4.2, there is no configure.exe inside the everywhere package. But the configure.bat could not executed in windows.


   Modify the file C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0\qtbase\configure.bat, which would generate configure.exe (about line 34):


@echo off
set QTSRC=%~dp0
set QTDIR=%CD%
rem if not exist %QTSRC%.gitignore goto sconf
echo Please wait while bootstrapping configure ...

for %%C in (cl.exe icl.exe g++.exe perl.exe) do set %%C=%%~$PATH:C

rem if "%perl.exe%" == "" (
rem     echo Perl not found in PATH. Aborting. >&2
rem     exit /b 1
rem )
if not exist mkspecs (
    md mkspecs
    if errorlevel 1 goto exit
)
rem perl %QTSRC%bin\syncqt.pl -minimal -module QtCore -outdir "%QTDIR%" %QTSRC%
rem if errorlevel 1 goto exit

if not exist tools\configure (
    md tools\configure
    if errorlevel 1 goto exit
)

Step 2:

Open the VS2010 prompt,  and configurate qt building parameters:


configure -platform  win32-msvc2010 -opensource -opengl desktop -release -nomake examples -no-angle -no-openssl -no-icu -skip translations -skip webkit  -no-openvg  -nomake tests -prefix C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0\built

That is for my buiding, you may need to modify the line.

Step 3:

  Before type "nmake", the environment variables need to be set ( temporarily):


C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0>SET VISUALDIR=C:\PROGRA~1\MICROS~1.0
C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0:>SET PATH=%VISUALDIR%\VC\bin;%PATH%
C:\Lib\Qt\qt-everywhere-opensource-src-5.5.0:>"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
 And the " NMAKE : fatal error U1077: 'cd' : return code '0x2' " would occur less frequently.

Step 4:
   Type nmake to build the qt libraries in windows via VS 2010.

   If that occurs :

nmake fatal error u1077 return code 0x2

keep to rerun nmake.

Step 5.

  After the building has been done, back to the qt root folder, type "nmake install", to organize the libraries be portable form.