VS2015 static compiler Qt5.5.1 (including Qtwebkit)

VS2015 static compiler Qt5.5.1 (including Qtwebkit)

kingbhy

2018.04.12 20:06* Word number 859

webkit is needed in the project, and the source code of webkit is investigated, but the source code is relatively large, and compiling with xcode is very convenient, but I am not familiar with programming under mac, so I can only do it after a period of research. Later, I learned that Qtwebkit has done a lot of streamlining work, and QT is more cross-platform friendly, so I turned to Qtwebkit. The first step is to compile Qt and Qtwebkit. This paper records the process of static compiling Qt 5.5.1 in VS2015, and makes some supplements and modifications by referring to relevant articles on the Internet.

Installation of required tools

The libraries and tools used below are all versions used by the compiler, and no other versions have been attempted.

  • python Use Version 2.7.14
  • ruby With version 25-x64, ruby official website documents require installation
  • perl Using 5.24, compiling webkit and OpenSSL needs
  • win_flex windows Compiler webkit Requirements
  • vs2015, you need to check the VC tool when installing

Source Code Compilation Directory

qt
    icu-58.2-vs2015
    openssl-1.0.2o
    win_flex_bison
    qt-everywhere-opensource-src-5.5.1

Compiling ICU and OpenSSL

  • If the ICU needs to modify the script of the official website for Direct static compilation, it is more troublesome. The good news is that someone has compiled the script statically and has passed it. Here You can download the compiled version directly, using v58.2 here. Note that v59.1 conflicts with webkit (mainly Problems of UCHAR)
  • There are many articles compiling OpenSSL under windows on OpenSSL. Here we refer to This article

Modify Qt static compilation parameters

Open qt-everywhere-opensource-src-5.5.1 qtbase mkspecs common msvc-desktop.conf and modify the following compilation parameters.

QMAKE_CFLAGS_RELEASE = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MDd

Change to

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

Modifying zlib compilation error reporting

Modifyqt-everywhere-opensource-src-5.5.1qt3dsrc3rdpartyassimpassimp.pri to

contains(QT_CONFIG, system-zlib) {
    unix|mingw: LIBS += -lz
    else: LIBS += zdll.lib
} else {
    INCLUDEPATH += $$[QT_INSTALL_HEADERS/get]/QtZlib
}

Amend to read

contains(QT_CONFIG, system-zlib) {
    if (unix|mingw):         LIBS += -lz
    else:                    LIBS += zdll.lib
    } else {
    git_build: \
        INCLUDEPATH += $$[QT_INSTALL_HEADERS/get]/QtZlib
    else: \
        INCLUDEPATH += $$[QT_INSTALL_HEADERS/src]/QtZlib
}

Compile Qt


REM Set up Microsoft Visual Studio 2015
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

ECHO ON

SET _CD=%CD%
SET _PATH=%PATH%

SET PATH=%PATH%;G:\qt\ninja-1.8.2\
SET PATH=%PATH%;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin
SET PATH=%PATH%;C:\python3.6\Scripts\;C:\python3.6\
SET PATH=%PATH%;C:\Ruby25-x64\bin

SET ICU_PCM_DIR=%_CD%\icu-58.2-vs2015
SET OPENSSL_DIR=%_CD%\openssl-1.0.2o
SET QT_SOURCE=%_CD%\qt-everywhere-opensource-src-5.8.0
SET QT_PREFIX=%_CD%\Qt5.5.1\qt-static

REM Setting ICU
SET PATH=%PATH%;%ICU_PCM_DIR%\bin

REM Building Qt
CALL %QT_SOURCE%\configure -confirm-license -opensource -platform win32-msvc2015 ^
    -debug-and-release -static -force-debug-info^
    -prefix %QT_PREFIX% ^
    -qt-sqlite -qt-pcre -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -qt-freetype ^
    -nomake tests -nomake examples ^
    -icu -I %ICU_PCM_DIR%\include -L %ICU_PCM_DIR%\lib^
    -openssl-linked -I %OPENSSL_DIR%\include -L %OPENSSL_DIR%\lib ^
    ICU_LIBS_DEBUG="-lsicudtd -lsicuind -lsicuucd -lAdvapi32" ^
    ICU_LIBS_RELEASE="-lsicudt -lsicuin -lsicuuc -lAdvapi32" ^
    OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" ^
    OPENSSL_LIBS_DEBUG="-llibeay32MTD -lssleay32MTD" ^
    OPENSSL_LIBS_RELEASE="-llibeay32MT -lssleay32MT"


nmake && nmake install

CD /D %_CD%
SET PATH=%_PATH%

Problems that may arise in running scripts:

  • There may be [rc.exe comamnd not found], which requires adding C: Program Files (x86) Windows Kits 8.1 bin x86 (maybe your machine is not this path) to PATH.
  • When making install, there is a copy exception. When copying qttranslations translations, modify the path related to qttranslations translations Makefiles. Debug and qttranslations translations Makefiles. Release.
  • In compiling ASSIMP, the report [zlib.h cannot be found], which is modified with reference to the previous zlib compilation error.

Compile Qtwebkit


REM Set up \Microsoft Visual Studio 2015
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86

ECHO ON

SET _CD=%CD%
SET _PATH=%PATH%

SET BUILD_MODE=debug
SET ICU_PCM_DIR=%_CD%\icu-58.2-vs2015
SET QT_SOURCE=%_CD%\qt-everywhere-opensource-src-5.5.1
SET QT_PREFIX=%_CD%\Qt5.5.1\vs2015-32
SET QTWEBKIT_PREFIX=%_CD%\Qt5.5.1\Qtwebkit

set PATH=%PATH%;%QT_PREFIX%\bin;%QT_SOURCE%\gnuwin32\bin;%_CD%\win_flex_bison
set INCLUDE=%INCLUDE%;%QT_PREFIX%\include;%ICU_PCM_DIR%\include;
set LIB=%LIB%;%QT_PREFIX%\lib;%QT_PREFIX%\plugins;%QT_PREFIX%\plugins\audio;%QT_PREFIX%\plugins\bearer;^
    %QT_PREFIX%\plugins\designer;%QT_PREFIX%\plugins\geoservices;%QT_PREFIX%\plugins\iconengines;^
    %QT_PREFIX%\plugins\imageformats;%QT_PREFIX%\plugins\mediaservice;%QT_PREFIX%\plugins\platforms;^
    %QT_PREFIX%\plugins\playlistformats;%QT_PREFIX%\plugins\position;%QT_PREFIX%\plugins\printsupport;^
    %QT_PREFIX%\plugins\qml1tooling;%QT_PREFIX%\plugins\qmltooling;%QT_PREFIX%\plugins\sensorgestures;^
    %QT_PREFIX%\plugins\sensors;%ICU_PCM_DIR%\lib;

perl %QT_SOURCE%\qtwebkit\Tools\Scripts\build-webkit --qt --%BUILD_MODE% --prefix=%QTWEBKIT_PREFIX%
CD /D %QT_SOURCE%\qtwebkit\WebKitBuild\%BUILD_MODE%
nmake install

CD /D %_CD%
SET PATH=%_PATH%

Problems that may arise in running scripts:

  • The external symbol [initializeTestFonts] that cannot be parsed has the following error:
 link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:..\..\bin\QtTestBrowser.exe @C:\Users\Ring\AppData\Local\Temp\nm3ED0.tmp
  //The library is being created. \\bin\QtTestBrowser.lib and objects. \\bin\QtTestBrowser.exp
qttestbrowser.obj : error LNK2019: Unparsable external symbols "__declspec(dllimport) void __cdecl WebKit::QtTestSupport::initializeTestFonts(void)" (__imp_?initializeTestFonts@QtTestSupport@WebKit@@YAXXZ),The sign is in the function. "private: void __thiscall LauncherApplication::handleUserOptions(void)" (?handleUserOptions@LauncherApplication@@AAEXXZ) Quoted
..\..\bin\QtTestBrowser.exe : fatal error LNK1120: 1 An unresolved external command

Need to modifyqt-everywhere-opensource-src-5.4.2\qtwebkitSourceWebCoreplatformqtQtTestSupport.h file, will

#if defined(BUILDING_WEBKIT)
#define TESTSUPPORT_EXPORT Q_DECL_EXPORT
#else
#define TESTSUPPORT_EXPORT Q_DECL_IMPORT
#endif

Amend to read

#if defined(BUILDING_WEBKIT)
#define TESTSUPPORT_EXPORT /*Q_DECL_EXPORT*/
#else
#define TESTSUPPORT_EXPORT /*Q_DECL_IMPORT*/
#endif
  • When compiling Qtwebkit for the first time, I encountered the unresolved external symbols (registerExtended Codecs), which changed the version of ICU to v58.2 and then compiled without appearing. If so, please refer to them. Here

Establishing Qtwebkit Project with VS2015

Problems encountered:

  • After running the project, there was a [nextafter] error. The specific reason was not found. Through the breakpoint, you can find \ qt-everywhere-opensource-src-5.5.1\ qtwebkit Source\ WTF wtf Mathras Ext.h, which will
inline double nextafter(double x, double y) { return _nextafter(x, y); }

Amend to read

inline double nextafter(double x, double y) { return x > y ? x - DBL_EPSILON : x + DBL_EPSILON; }

Then recompile the webkit

 

 

Keywords: Qt OpenSSL zlib Windows

Added by Benjigga on Mon, 02 Sep 2019 14:54:49 +0300