Building Qt-4.8.7 and qtwebkit-2.3.4 Separately with VS2012 on Windows

From Qt Wiki
Jump to navigation Jump to search

Building Qt on Windows is quite a difficult work, while the work on OS X and Ubuntu is really simple. The main problem is QtWebKit. Official release provides precompiled Qt4 SDKs for VS2010 but not VS2012; project qt64ng on http://sourceforge.net/projects/qt64ng/ also provides Qt4 SDKs for VS2012 and VS2013, but not detail building steps.

Tutorials on internet provide some instructions on building Qt-4.8 with VS2012, but the generated QtWebKit4.dll doesn't work, encountering error StackHash_0a9e (tested on Win7 and Win10). This tutorial focus on details of building Qt-4.8.7, qtwebkit-2.3.4 and qtcreator-2.8.1.

Preparations

Install Visual Studio 2012 Express for Desktop

Use tool 'Developer Command Prompt for VS2012' for following jobs.

Install perl

http://www.activestate.com/activeperl

Build OpenSSL

Download source code: http://www.openssl.org/source/openssl-1.0.2d.tar.gz

Decompress to directory: C:\Users\username\Downloads\openssl-1.0.2d

Compile and install(installing directory: C:\OpenSSL)

cd C:\Users\username\Downloads\openssl-1.0.2d

perl Configure VC-WIN32 no-asm --prefix=C:\OpenSSL

ms\do_ms

nmake -f ms\ntdll.mak

nmake -f ms\ntdll.mak install

Append C:\OpenSSL\bin to system path

Build Qt-4.8.7 without qtwebkit(-no-webkit)

Change work directory to Qt source root directory, and run:

configure -mp -prefix C:\Qt\4.8.7 -release -confirm-license -opensource -qt-zlib -qt-libjpeg -qt-libpng -qt-libmng qt-libtiff -no-qt3support -no-webkit -nomake demos -nomake examples -openssl -I C:\OpenSSL\include -L C:\OpenSSL\lib

Compile Qt source:

namke

(It takes about 2hr to finish compiling.)

Install Qt SDK:

namke install

Append C:/Qt/4.8.7/bin to system path

Build QtWebKit-2.3.4

Download source code from

http://download.kde.org/stable/qtwebkit-2.3/2.3.4/src/qtwebkit-2.3.4.tar.gz

Note that the lastest WebKit source code from webkit.org doesn't support .

Install necessary tools for building qtwebkit:

GNUWIN32

http://sourceforge.net/projects/gnuwin32/ or from gnuwin32 in Qt-5.5.0 source code directory

python

https://www.python.org/ftp/python/2.7.10/python-2.7.10.msi

ruby

https://www.ruby-lang.org/en/downloads/

perl(already installed)

http://www.activestate.com/activeperl

Make sure binaries directories of above tools are in system path.

sqlite source code

http://sqlite.org/2015/sqlite-amalgamation-3081101.zip

Decompress it to:

C:\Users\username\Downloads\sqlite3

Compile qtwebkit:

set SQLITE3SRCDIR=C:\Users\username\Downloads\sqlite3

set QTDIR=C:\Qt\4.8.7

perl Tools\Scripts\build-webkit --qt --release

It takes about 4hr to finish compiling.

Install QtWebKit:

cd WebKitBuild/Release

nmake install

Test QtWebKit

In fact,after buidling QtWebKit,a test program called QtTestBrowser.exe is located in WebKitBuild/Release/bin directory.

Your can also build project browser in Qt source directory(say %QTSRC%/demos):

cd %QTSRC%/demos/browser

qmake

nmake

Building QtCreator-2.8.1 with Qt-4.8.7 and MSVC 2012

cd %QTCREATORSRC%

qmake CONFIG+=release qtcreator.pro

nmake

namke install INSTALL_ROOT=C:\Qt\qtcreator-2.8.1

You will encouter following errors:

c:\users\username\downloads\qt-creator-2.8.1-src\src\libs\utils\consoleprocess _p.h(49) : fatal error C1083: Cannot open include file: 'private\qwineventnotifi er_p.h': No such file or directory winutils.cpp Generating Code... NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 11.0\VC\BI N\cl.EXE"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 11.0\VC\BI N\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop. NMAKE : fatal error U1077: 'cd' : return code '0x2' Stop.

The reason is that some headers haven't been installed, you should copy headers in directory

C:\Users\username\Downloads\qt-everywhere-opensource-src-4.8.7\src\corelib\kernel

to

C:\Qt\4.8.7\include\QtCore\private

then, run nmake to continue.

Enjoy Qt built by yourself!

References

http://www.linuxfromscratch.org/blfs/view/svn/x/qt4.html

http://trac.webkit.org/wiki/QtWebKit

http://trac.webkit.org/wiki/BuildingQtOnWindows