вторник, 29 октября 2013 г.

Building Qt5.1.1 with VS2012 and WebKit targeting on Windows XP


Qt 5.1.1
Microsoft Visual Studio 2012 Update 3
WebKit
Targeting on Windows XP



Qt5.1.1 && VS2012 && WinXP && WebKit build steps
!!! PLEASE, before you do anything described here read to the end
and sorry for my english

.::prepare steps::.
1. Download source code as a single zip
(http://download.qt-project.org/official_releases/qt/5.1/5.1.1/single/qt-everywhere-opensource-src-5.1.1.zip)
2. Install Visual Studio 2012
3. Install Windows SDK
4. Install Update 3 for Visual Studio 2012
5. Install
(http://www.python.org/download/releases/)
6. Install Perl
(http://www.activestate.com/activeperl/downloads)
7. Install Ruby
(http://www.rubyinstaller.org/)
8. Install ICU (for example to "C:\icu" must have dirs: "bin", "include", "lib")
(http://site.icu-project.org/)
 be sure what %PATH% have "C:\icu\bin"
9. Install pthreads-win32 (for example to "C:\pthreads-win32")
(https://sourceware.org/pthreads-win32/)
 to environment variables add:
 INCLUDE=C:\pthreads-win32\include
 LIB=C:\pthreads-win32\lib\x86
 PATH=C:\pthreads-win32\dll\x86
10. Be sure what Qt sources include gnuwin32 dir
(or install it separately, must have "bison", "flex" and "gperf")
11. Install OpenSSL (for example to "OpenSSL-Win32" must have dirs: "bin", "include", "lib")
(http://slproweb.com/download/Win32OpenSSL-1_0_1e.exe)

.::configuring Qt::.
12. Start a command prompt, checkout to dir with sources and that sets up the environment variables:

    set QT_SOURCE=C:\Qt\Qt5.1.1-XP-src
    call "%ProgramFiles%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
    set PATH=%QT_SOURCE%\qtbase\bin;%QT_SOURCE%\qtrepotools\bin;%QT_SOURCE%\gnuwin32\bin;%PATH%
    set QMAKESPEC=win32-msvc2012

    set INCLUDE=%ProgramFiles%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
    set PATH=%ProgramFiles%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
    set LIB=%ProgramFiles%\Microsoft SDKs\Windows\v7.1A\Lib;%LIB%
    set CL=/D_USING_V110_SDK71_;%CL%

(I can't remember why it need, but nothing wrong it does not make)
    set QTDIR=C:\Qt\Qt5.1.1-XP
    set PATH=C:\Qt\Qt5.1.1-XP\bin;%PATH%

(for assembling by jom instead of nmake)
    set PATH=C:\Qt\qtcreator-2.8.1\bin;%PATH%

13. Modify two lines in the makespec file
qtbase\mkspecs\win32-msvc2012\qmake.conf

QMAKE_LFLAGS_CONSOLE    = /SUBSYSTEM:CONSOLE,5.01
QMAKE_LFLAGS_WINDOWS    = /SUBSYSTEM:WINDOWS,5.01

14. Modify the file
qtbase\src\corelib\io\qfilesystemengine_win.cpp
by adding a third OR component to the conditional on line 574:

#  if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && _MSC_VER < 1700) || (defined(Q_CC_MSVC) && _MSC_VER >= 1700 && defined(_USING_V110_SDK71_))

15. Modify the file
qtbase\qmake\Makefile.win32
by adding the SDK7 macro to the CFLAGS_BARE variable so qmake will build without all the redefinition warnings:

CFLAGS_BARE = -c -Fo./ \
              <...snip...>
              -DUNICODE -D_USING_V110_SDK71_

16. Modify the file
qtbase\mkspecs\win32-msvc2012\qmake.conf
add the SDK7 macro to the QMAKE_CFLAGS variable:

QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t -D_USING_V110_SDK71_

17.1 Configure string:

In case when you want Qt without WebKit (for building by nmake):

configure.bat -debug-and-release -opensource -confirm-license -c++11 -shared -ltcg -skip qtquick1 -skip qtquickcontrols -skip qtjsbackend -skip qtdeclarative -no-opengl -no-angle -no-qml-debug -plugin-sql-sqlite -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32\lib -openssl -I C:\icu\include -L C:\icu\lib -icu -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -mp -nomake examples -prefix C:\Qt\Qt5.1.1-XP

in next configure cases specified -make-tool jom
and
do not require execution items beginning from 18

In case when you want Qt with WebKit and angle:

configure.bat -debug-and-release -opensource -confirm-license -c++11 -shared -ltcg -plugin-sql-sqlite -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32\lib -openssl -I C:\icu\include -L C:\icu\lib -icu -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -make-tool jom -nomake examples -prefix C:\Qt\Qt5.1.1-XP

In case when you want Qt with WebKit and full OpenGL (my choice):
configure.bat -debug-and-release -opensource -confirm-license -c++11 -shared -ltcg -plugin-sql-sqlite -opengl desktop -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32\lib -openssl -I C:\icu\include -L C:\icu\lib -icu -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -make-tool jom -nomake examples -prefix C:\Qt\Qt5.1.1-XP

Configure results:
Expand


See difference between ANGLE and OpenGL there
http://qt-project.org/wiki/Qt-5-on-Windows-ANGLE-and-OpenGL

17.2 Be sure what you have more then 2GB Ram or have enough size of your pagefile (virtual memory)
Run:
jom
..if scpecified this make-tool in configuring string or:
nmake

17.2.1 wait wait wait :)
Qt building took 6-7 hours on i5 2.4Ghz x2 cores (VM) (with webkit, without - about 2h)

17.3 jom (nmake) install

.::run new GUI project::.
18. In .pro file add next lines (maybe not all needed,
I do not yet check yet which of them are really necessary)

win32 {
    LIBS *= -L"%ProgramFiles%\Microsoft SDKs\Windows\v7.1A\Lib"
    INCLUDEPATH += "%ProgramFiles%\Microsoft SDKs\Windows\v7.1A\Include"
    QMAKE_CXX += /D_USING_V110_SDK71_
    QMAKE_LFLAGS += /SUBSYSTEM:CONSOLE,5.01
    DEFINES += "WINVER=0x0501"
    DEFINES += WIN32 _WIN32_WINNT=0x0501
}

In my case enough was only:

DEFINES += "WINVER=0x0501"
DEFINES += WIN32 _WIN32_WINNT=0x0501

19. Move app with necessary libs and to WinXP.
Necessary libs in my case (from C:\Qt\Qt5.1.1-XP\lib):

Also needed icu* files
(manually need to place the ICU libraries into the qtbase\bin directory):
icuuc52.dll
icuin52.dll
icudt52.dll
(btw. by default installed Qt5.1.1 used icu*51.dll)

20. Must be runned succesfully. (I got it)

.::build QtWebKit::.
(if you want build only WebKit, I did not manage make friends builded separately qtbase and qtwebkit)
21. When I did with:

set PATH=%PATH%;%CD%\gnuwin32\bin
cd qtwebkit
set WEBKITOUTPUTDIR=%CD%\WebKitBuild
perl Tools\Scripts\build-webkit --qt --qmake="%CD%\\..\\qtbase\\bin\\qmake.exe" --install-libs=C:\Qt\Qt5.1.1-XP\lib --install-headers=C:\Qt\Qt5.1.1-XP\include\QtWebKit --release

 - I had a linker error described in this bug:
 https://bugreports.qt-project.org/browse/QTBUG-20556?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel

 21.1 Therefore I applied this patch:
 https://bug-119238-attachments.webkit.org/attachment.cgi?id=207699

 That is, in the file:
 C:\Qt\Qt5.1.1-XP-src\qtwebkit\Source\WebCore\WebCore.pri
 has replaced row (line 270)
 win32-msvc2005|win32-msvc2008|win32-msvc2010|win32-msvc2012|wince*:{
 instead of
 win32-msvc2005|win32-msvc2008|win32-msvc2010|wince*:{

In bugreport said about that it bug fixed in Qt5.1.1 which I use currently,
but it's wrong information

22. In building time I had link error:
...
DumpRenderTreeMain.obj : error LNK2001: unresolved external symbol _WTFInstallReportBacktraceOnCrashHook
...

..it's only happens when I tried build only release version of WebKit

23. But libs was succesfully builded and Test programm QtTestBrowser.exe with newly created WebKit dll's
and libs from my Qt5 for XP was succesfylly runned.

24. But I was stuppid and forgot about debug libs and was run build script with next arguments:

perl Tools\Scripts\build-webkit --qt --qmake="%CD%\\..\\qtbase\\bin\\qmake.exe" --install-libs=C:\Qt\Qt5.1.1-XP\lib --install-headers=C:\Qt\Qt5.1.1-XP\include\QtWebKit --debug

24.1 Before it made backup of WebKitBuild folder (there leaves release builded libs)

25. Debug building was succesfull and test QtTestBrowser.exe was succesfully runned on WinXP

(debug and release)
perl Tools\Scripts\build-webkit --qt --install-libs=C:\Qt\Qt5.1.1-XP\lib --install-headers=C:\Qt\Qt5.1.1-XP\include

====================================================================
 WebKit is now built (5h:48m:43s).
 To run QtTestBrowser with this newly-built code, use the
 "Tools\Scripts/run-launcher" script.
====================================================================

also you can:

 It is possible to build selected modules with their dependencies by doing
 a `make module-'.  For example, to build only qtscript and qtwebkit,
 and the modules they depend on:

   ./configure -prefix $PWD/qtbase -opensource
   make -j4 module-qtscript module-qtwebkit

P.S. Used links:

http://qt-project.org/forums/viewthread/30126
http://qt-project.org/forums/viewthread/26565
http://trac.webkit.org/wiki/BuildingQtOnWindows
http://qt-project.org/wiki/Building-Qt-5-from-Git-Russian#64880e1411ae5f0e25c4558858830a99 (on Russian)
http://blog.mgsxx.com/?p=2614 (on Russian)

P.P.S. Qt building took 1:30 hours on i5 2.4Ghz x2 cores (VM)
P.P.P.S. QtWebKit took 3:22 hours on i5 2.4Ghz x2 cores (VM)

P.P.P.P.S:
As it turned out for my purposes (targeting on Windows XP) do not need to be assemble separately Qt.
Was enough to rebuild all my dependencies (libs used in project) with Visual Studio Update 3 and
specify in .pro file:
DEFINES += "WINVER=0x0501"
DEFINES += WIN32 _WIN32_WINNT=0x0501

But if my work will help someone, I'll be happy :)

Комментариев нет:

Отправить комментарий