如何让Qt4/5使用VS2012构建,同时针对Windows XP



我正在尝试使用Visual Studio 2012构建Qt 4.8.5/Qt 5.2.1,目标是Windows XP(SDK v7.1a)。在使用VS2102编译时,源代码与SDK v7.1a存在各种不兼容之处,因此无法开箱即用。

这将是一个规范的问题,它提供了在这样的环境中成功构建Qt所需的知识。

首先,构建环境需要按照以下方式进行准备。注意:这个剧本"有很多变体"存在拼写错误,这实际上是一个禁忌。

@call "C:Program Files (x86)Microsoft Visual Studio 11.0VCvcvarsall.bat" x86
:: The below applies to XP-targeting builds *only*!
@set INCLUDE=%ProgramFiles(x86)%Microsoft SDKsWindowsv7.1AInclude;%INCLUDE%
@set PATH=%ProgramFiles(x86)%Microsoft SDKsWindowsv7.1ABin;%PATH%
@set LIB=%ProgramFiles(x86)%Microsoft SDKsWindowsv7.1ALib;%LIB%

问题5.2

首先,我们注意到Qt源应该保持原始,这样现有的构建就不会被破坏。我们不会改变现有的生产规格。因此:

  1. 通过从qtbase/mkspecs/win32-msvc2012复制一个单独的win32-msvc2012-xpqmake规范来创建它。修改它。

  2. 教授configure和qmake makefile关于新的qmake规范

  3. 通过在qtbase中创建一个空的.gitignore文件来强制引导config.exe。

下面的脚本和补丁处理这个过程。

:: Assume that we're in an equivalent of C:Qt prefix
@set PREFIX=%~dp0
:: Qt sources
@set QT=%PREFIX%..5.2.1-src
:: Patch file(s)
@set SRC=%PREFIX%
@set SPEC=win32-msvc2012
@if not exist "%QT%qt.pro" ( echo Qt source folder expected in %QT%>&2 & exit /b 1 )
::
@patch --forward --directory=%QT% -p0 --global-reject-file=%SRC%qt5fixes.rej --input=%SRC%qt5fixes.patch
::
@echo > %QT%qtbase.gitignore
@mkdir %QT%qtbasemkspecs%SPEC%-xp
@copy %QT%qtbasemkspecs%SPEC%qplatformdefs.h %QT%qtbasemkspecs%SPEC%-xp
@copy %QT%qtbasemkspecs%SPEC%qmake.conf %QT%qtbasemkspecs%SPEC%-xp
@patch --forward --directory=%QT% -p0 --global-reject-file=%SRC%qt5xp.rej --input=%SRC%qt5xp.patch

撤消更改,请运行以下操作(变量必须如上所述设置):

@patch --reverse --directory=%QT% -p0 --global-reject-file=%SRC%qt5xp-unfix.rej --input=%SRC%qt5xp.patch
@del %QT%qtbasemkspecs%SPEC%-xpqplatformdefs.h
@del %QT%qtbasemkspecs%SPEC%-xpqmake.conf
@rmdir %QT%qtbasemkspecs%SPEC%-xp
@del %QT%qtbase.gitignore

然后通过执行来执行构建

configure -platform win32-msvc2012-xp
jom (or nmake)
jom install (if doing the build separate from the installation directory)

这个make规范还支持静态构建(给定要配置的-static),但需要注意的是MSVC2012运行时仍然是动态链接的。对静态MSVC运行时的支持是另一个问题。

# qt5fixes.patch
# Fix for QTBUG-32519: Fix for preprocessor.lib not getting installed
--- qtbase/src/angle/src/compiler/preprocessor/preprocessor.pro 2014-02-01 22:37:36.000000000 -0500
+++ qtbase/src/angle/src/compiler/preprocessor/preprocessor.pro 2014-02-18 18:11:00.472660600 -0500
@@ -4,6 +4,10 @@
include(../../config.pri)
+contains(QT_CONFIG, static) {
+    load(qt_installs)
+}
+
INCLUDEPATH = $$ANGLE_DIR/src/compiler/preprocessor
DEFINES += _SECURE_SCL=0
# Fix for QTBUG-32519: Fix for translator_common.lib not getting installed
--- qtbase/src/angle/src/compiler/translator_common.pro 2014-02-01 22:37:36.000000000 -0500
+++ qtbase/src/angle/src/compiler/translator_common.pro 2014-02-18 18:08:51.596661200 -0500
@@ -4,6 +4,10 @@
include(../config.pri)
+contains(QT_CONFIG, static) {
+    load(qt_installs)
+}
+
# Mingw 4.7 chokes on implicit move semantics, so disable C++11 here
win32-g++*: CONFIG -= c++11
# Fix for QTBUG-32519: Fix for translator_hlsl.lib not getting installed
--- qtbase/src/angle/src/compiler/translator_hlsl.pro   2014-02-01 22:37:36.000000000 -0500
+++ qtbase/src/angle/src/compiler/translator_hlsl.pro   2014-02-18 18:09:54.651312600 -0500
@@ -4,6 +4,10 @@
include(../config.pri)
+contains(QT_CONFIG, static) {
+    load(qt_installs)
+}
+
# Mingw 4.7 chokes on implicit move semantics, so disable C++11 here
win32-g++*: CONFIG -= c++11
# Fix for QTBUG-36951: Make ANGLE binary compatible with rest of Qt
--- qtbase/src/angle/src/config.pri 2014-02-01 15:37:36.000000000 -0500
+++ qtbase/src/angle/src/config.pri 2014-02-20 04:26:52.535186300 -0500
@@ -54,7 +54,6 @@
CONFIG(debug, debug|release) {
DEFINES += _DEBUG
} else {
-    CONFIG += rtti_off
DEFINES += NDEBUG
}
# qt5xp.patch
# XP Targeting Support for Qt 5.2
#
# Get configure to recognize all qmake specs that begin with a known prefix.
--- qtbase/tools/configure/environment.cpp  2014-02-01 15:37:29.000000000 -0500
+++ qtbase/tools/configure/environment.cpp  2014-02-18 13:14:37.321371600 -0500
@@ -149,23 +149,23 @@
Compiler Environment::compilerFromQMakeSpec(const QString &qmakeSpec)
{
-    if (qmakeSpec == QLatin1String("win32-msvc2013"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-msvc2013")))
return CC_NET2013;
-    if (qmakeSpec == QLatin1String("win32-msvc2012"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-msvc2012")))
return CC_NET2012;
-    if (qmakeSpec == QLatin1String("win32-msvc2010"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-msvc2010")))
return CC_NET2010;
-    if (qmakeSpec == QLatin1String("win32-msvc2008"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-msvc2008")))
return CC_NET2008;
-    if (qmakeSpec == QLatin1String("win32-msvc2005"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-msvc2005")))
return CC_NET2005;
-    if (qmakeSpec == QLatin1String("win32-msvc2003"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-msvc2003")))
return CC_NET2003;
-    if (qmakeSpec == QLatin1String("win32-icc"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-icc")))
return CC_INTEL;
-    if (qmakeSpec == QLatin1String("win32-g++"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-g++")))
return CC_MINGW;
-    if (qmakeSpec == QLatin1String("win32-borland"))
+    if (qmakeSpec.startsWith(QLatin1String("win32-borland")))
return CC_BORLAND;
return CC_UNKNOWN;
}
# Build configure with XP targeting.
--- qtbase/configure.bat    2014-02-01 15:37:23.000000000 -0500
+++ qtbase/configure.bat    2014-02-18 13:22:34.356160100 -0500
@@ -70,7 +70,7 @@
for /f "tokens=3 usebackq" %%V in (`findstr QT_VERSION_STR %QTSRC%srccorelibglobalqglobal.h`) do @echo QTVERSION = %%~V>> Makefile
if not "%cl.exe%" == "" (
echo CXX = cl>>Makefile
-    echo EXTRA_CXXFLAGS =>>Makefile
+    echo EXTRA_CXXFLAGS = -D_USING_V110_SDK71_>>Makefile
rem This must have a trailing space.
echo QTSRC = %QTSRC% >> Makefile
set tmpl=win32
# Build qmake with XP targeting.
--- qtbase/qmake/Makefile.win32 2014-02-20 12:24:10.341305900 -0500
+++ qtbase/qmake/Makefile.win32 2014-02-20 12:28:23.316380600 -0500
@@ -42,6 +42,9 @@
-DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS 
-DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM 
-DUNICODE -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY
+!if "$(QMAKESPEC)" == "win32-msvc2012-xp"
+CFLAGS_BARE = $(CFLAGS_BARE) -D_USING_V110_SDK71_
+!endif
CFLAGS   = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch $(CFLAGS_BARE) $(CFLAGS) $(EXTRA_CPPFLAGS)
CXXFLAGS_BARE = $(CFLAGS_BARE)
# Let qmake recognize the XP targeting makespec
--- qtbase/qmake/Makefile.win32 2014-02-01 22:37:30.000000000 -0500
+++ qtbase/qmake/Makefile.win32 2014-02-17 16:21:09.329949100 -0500
@@ -1,4 +1,4 @@
-!IF "$(QMAKESPEC)" == "win32-msvc" || "$(QMAKESPEC)" == "win32-msvc.net" || "$(QMAKESPEC)" == "win32-msvc2002" || "$(QMAKESPEC)" == "win32-msvc2003" || "$(QMAKESPEC)" == "win32-msvc2005" || "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-msvc2013" || "$(QMAKESPEC)" == "win32-icc"
+!IF "$(QMAKESPEC)" == "win32-msvc" || "$(QMAKESPEC)" == "win32-msvc.net" || "$(QMAKESPEC)" == "win32-msvc2002" || "$(QMAKESPEC)" == "win32-msvc2003" || "$(QMAKESPEC)" == "win32-msvc2005" || "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-msvc2012-xp" || "$(QMAKESPEC)" == "win32-msvc2013" || "$(QMAKESPEC)" == "win32-icc"
!if "$(SOURCE_PATH)" == ""
SOURCE_PATH = ..
# XP targeting makespec
--- qtbase/mkspecs/win32-msvc2012-xp/qmake.conf 2014-02-01 22:37:38.000000000 -0500
+++ qtbase/mkspecs/win32-msvc2012-xp/qmake.conf 2014-02-17 16:08:47.204498000 -0500
@@ -7,7 +7,7 @@
MAKEFILE_GENERATOR      = MSBUILD
QMAKE_PLATFORM          = win32
CONFIG                 += incremental flat precompile_header autogen_precompile_source debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe
-DEFINES                += UNICODE WIN32
+DEFINES                += UNICODE WIN32 _USING_V110_SDK71_
QMAKE_COMPILER_DEFINES += _MSC_VER=1700 _WIN32
contains(QMAKE_TARGET.arch, x86_64) {
DEFINES += WIN64
@@ -69,8 +69,13 @@
QMAKE_LFLAGS_RELEASE    = /INCREMENTAL:NO
QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO = /DEBUG /OPT:REF /INCREMENTAL:NO
QMAKE_LFLAGS_DEBUG      = /DEBUG
-QMAKE_LFLAGS_CONSOLE    = /SUBSYSTEM:CONSOLE
-QMAKE_LFLAGS_WINDOWS    = /SUBSYSTEM:WINDOWS
+contains(QMAKE_TARGET.arch, x86_64) {
+   QMAKE_LFLAGS_CONSOLE    = /SUBSYSTEM:CONSOLE,5.02
+   QMAKE_LFLAGS_WINDOWS    = /SUBSYSTEM:WINDOWS,5.02
+} else {
+   QMAKE_LFLAGS_CONSOLE    = /SUBSYSTEM:CONSOLE,5.01
+   QMAKE_LFLAGS_WINDOWS    = /SUBSYSTEM:WINDOWS,5.01
+}
QMAKE_LFLAGS_EXE        = "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'"
QMAKE_LFLAGS_DLL        = /DLL
QMAKE_LFLAGS_LTCG       = /LTCG
# Add support for XP targeting.
--- qtbase/src/corelib/io/qfilesystemengine_win.cpp 2014-02-01 22:37:36.000000000 -0500
+++ qtbase/src/corelib/io/qfilesystemengine_win.cpp 2014-02-17 16:20:29.612858300 -0500
@@ -571,7 +571,7 @@
// FILE_INFO_BY_HANDLE_CLASS has been extended by FileIdInfo = 18 as of VS2012.
typedef enum { Q_FileIdInfo = 18 } Q_FILE_INFO_BY_HANDLE_CLASS;
-#  if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && _MSC_VER < 1700)
+#  if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && _MSC_VER < 1700) || (defined(Q_CC_MSVC) && _MSC_VER >= 1700 && defined(_USING_V110_SDK71_))
// MinGW-64 defines FILE_ID_128 as of gcc-4.8.1 along with FILE_SUPPORTS_INTEGRITY_STREAMS
#    if !(defined(Q_CC_MINGW) && defined(FILE_SUPPORTS_INTEGRITY_STREAMS))
# Add support for XP targeting.
--- qtbase/src/corelib/kernel/qeventdispatcher_win.cpp  2014-02-17 17:29:02.552706900 -0500
+++ qtbase/src/corelib/kernel/qeventdispatcher_win.cpp  2014-02-17 17:25:26.662602800 -0500
@@ -435,7 +435,7 @@
UINT result = QS_TIMER | QS_INPUT | QS_RAWINPUT;
// QTBUG 28513, QTBUG-29097, QTBUG-29435: QS_TOUCH, QS_POINTER became part of
// QS_INPUT in Windows Kit 8. They should not be used when running on pre-Windows 8.
-#if defined(_MSC_VER) && _MSC_VER >= 1700
+#if defined(_MSC_VER) && _MSC_VER >= 1700 && !defined(_USING_V110_SDK71_)
if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8)
result &= ~(QS_TOUCH | QS_POINTER);
#endif //  _MSC_VER >= 1700

Qt 5.3及以后版本不需要任何额外的补丁:只需使用"-target xp"运行configure即可。

不过,你需要设置正确的环境,就像其他答案中建议的那样

"C:Program Files (x86)Microsoft Visual Studio 12.0VCvcvarsall.bat"
set PATH=C:Program Files (x86)Microsoft SDKsWindowsv7.1ABin;%PATH%
set INCLUDE=C:Program Files (x86)Microsoft SDKsWindowsv7.1AInclude;%INCLUDE%
set LIB=C:Program Files (x86)Microsoft SDKsWindowsv7.1AInclude;%LIB%
set CL=/D_USING_V110_SDK71_

(CL=/D_USING_V110_SDK71_可防止Windows标头发出大量警告)。

构建环境需要按照如下方式进行准备。注意:这个剧本"有很多变体"存在拼写错误,这实际上是一个禁忌。

@call "C:Program Files (x86)Microsoft Visual Studio 11.0VCvcvarsall.bat" x86
:: The below applies to XP-targeting builds *only*!
@set INCLUDE=%ProgramFiles(x86)%Microsoft SDKsWindowsv7.1AInclude;%INCLUDE%
@set PATH=%ProgramFiles(x86)%Microsoft SDKsWindowsv7.1ABin;%PATH%
@set LIB=%ProgramFiles(x86)%Microsoft SDKsWindowsv7.1ALib;%LIB%

问题4.8

以下脚本修补源:

:: Assume that we're in an equivalent of C:Qt prefix
@set PREFIX=%~dp0
:: Qt sources
@set QT=%PREFIX%..4.8.5-src
:: Patch file(s)
@set SRC=%PREFIX%
@set SPEC=win32-msvc2012
@if not exist "%QT%projects.pro" ( echo Qt source folder expected in %QT%>&2 & exit /b 1 )
::
@patch --forward --directory=%QT% -p0 --global-reject-file=%SRC%qt4fixes.rej --input=%SRC%qt4fixes.patch
::
@mkdir %QT%mkspecs%SPEC%-xp
@copy %QT%mkspecs%SPEC%qplatformdefs.h %QT%mkspecs%SPEC%-xp
@copy %QT%mkspecs%SPEC%qmake.conf %QT%mkspecs%SPEC%-xp
@patch --forward --directory=%QT% -p0 --global-reject-file=%SRC%qt4xp.rej --input=%SRC%qt4xp.patch

要撤消更改,请运行以下命令:

@patch --reverse --directory=%QT% -p0 --global-reject-file=%SRC%qt4static-unfix.rej --input=%SRC%qt4static.patch
@del %QT%mkspecs%SPEC%-staticqplatformdefs.h
@del %QT%mkspecs%SPEC%-staticqmake.conf
@rmdir %QT%mkspecs%SPEC%-static
@del %QT%mkspecs%SPEC%-static-xpqplatformdefs.h
@del %QT%mkspecs%SPEC%-static-xpqmake.conf
@rmdir %QT%mkspecs%SPEC%-static-xp

然后通过执行来执行构建

configure -platform win32-msvc2012-xp
jom (or nmake)
# qt4fixes.patch
#
# Fix for HashSet under MSVC2012/2013.
--- src/3rdparty/webkit/Source/JavaScriptCore/wtf/HashSet.h 2013-06-07 09:16:54.000000000 -0400
+++ src/3rdparty/webkit/Source/JavaScriptCore/wtf/HashSet.h 2013-09-27 12:20:48.148285400 -0400
@@ -174,12 +174,23 @@
return m_impl.template contains<T, Adapter>(value);
}
+   /*
template<typename T, typename U, typename V>
inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
{
return m_impl.add(value);
}
+   */
+   // fix
+   template<typename T, typename U, typename V>
+   inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
+   {
+       typedef typename HashSet<T, U, V>::iterator iter_type;
+       auto& temp = m_impl.add(value);
+       return make_pair((iter_type)temp.first, temp.second);
+   }
+   /*
template<typename Value, typename HashFunctions, typename Traits>
template<typename T, typename HashTranslator>
inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
@@ -188,6 +199,18 @@
typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
return m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
}
+   */
+   // fix
+   template<typename Value, typename HashFunctions, typename Traits>
+   template<typename T, typename HashTranslator>
+   inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
+   HashSet<Value, HashFunctions, Traits>::add(const T& value)
+   {
+       typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
+       typedef typename HashSet<Value, HashFunctions, Traits>::iterator iter_type;
+       auto& temp = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
+       return make_pair((iter_type)temp.first, temp.second);
+   }
template<typename T, typename U, typename V>
inline void HashSet<T, U, V>::remove(iterator it)
# qt4xp.patch
# XP Targeting Support for Qt 4.8
#
# Build configure with XP targeting
--- tools/configure/configure.pro   2013-06-07 09:17:02.000000000 -0400
+++ tools/configure/configure.pro   2014-02-20 10:00:29.840317000 -0500
@@ -4,6 +4,7 @@
CONFIG   += console flat stl rtti_off
CONFIG   -= moc qt
DEFINES  = UNICODE QT_NODLL QT_NO_CODECS QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_LITE_COMPONENT QT_NO_STL QT_NO_COMPRESS QT_NO_THREAD QT_NO_QOBJECT QT_NO_GEOM_VARIANT _CRT_SECURE_NO_DEPRECATE
+win32-msvc2012-xp: DEFINES += _USING_V110_SDK71_
DEFINES  += QT_BOOTSTRAPPED
win32 : LIBS += -lole32 -ladvapi32
@@ -19,7 +20,7 @@
QMAKE_CXXFLAGS_DEBUG -= -MDd
QMAKE_CXXFLAGS_DEBUG += -MTd
}
-win32-msvc2012: DEFINES += _ALLOW_KEYWORD_MACROS
+win32-msvc2012*: DEFINES += _ALLOW_KEYWORD_MACROS
PRECOMPILED_HEADER = configure_pch.h
# Build qmake with XP targeting
--- qmake/Makefile.win32    2013-06-07 09:17:02.000000000 -0400
+++ qmake/Makefile.win32    2014-02-20 09:31:51.090426700 -0500
@@ -1,4 +1,4 @@
-!IF "$(QMAKESPEC)" == "win32-msvc" || "$(QMAKESPEC)" == "win32-msvc.net" || "$(QMAKESPEC)" == "win32-msvc2002" || "$(QMAKESPEC)" == "win32-msvc2003" || "$(QMAKESPEC)" == "win32-msvc2005" || "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-icc"
+!IF "$(QMAKESPEC)" == "win32-msvc" || "$(QMAKESPEC)" == "win32-msvc.net" || "$(QMAKESPEC)" == "win32-msvc2002" || "$(QMAKESPEC)" == "win32-msvc2003" || "$(QMAKESPEC)" == "win32-msvc2005" || "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-msvc2012-xp" || "$(QMAKESPEC)" == "win32-icc"
!if "$(SOURCE_PATH)" == ""
SOURCE_PATH = ..
# Build qmake with XP targeting
--- qmake/Makefile.win32    2013-06-07 09:17:02.000000000 -0400
+++ qmake/Makefile.win32    2014-02-20 09:31:51.090426700 -0500
@@ -42,6 +42,9 @@
-DQT_NO_COMPRESS -DUNICODE -DHAVE_QCONFIG_CPP -DQT_BUILD_QMAKE -DQT_NO_THREAD 
-DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_NO_PCRE -DQT_BOOTSTRAPPED 
-DQLIBRARYINFO_EPOCROOT
+!if "$(QMAKESPEC)" == "win32-msvc2012-xp"
+CFLAGS_BARE = $(CFLAGS_BARE) -D_USING_V110_SDK71_
+!endif
CFLAGS   = -Yuqmake_pch.h -FIqmake_pch.h -Fpqmake_pch.pch $(CFLAGS_BARE) $(CFLAGS)
CXXFLAGS_BARE = $(CFLAGS_BARE)
--- mkspecs/win32-msvc2012-xp/qmake.conf    2013-06-07 09:17:00.000000000 -0400
+++ mkspecs/win32-msvc2012-xp/qmake.conf    2014-02-17 16:17:38.831119700 -0500
@@ -8,7 +8,7 @@
TEMPLATE                = app
CONFIG                  += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe
QT                      += core gui
-DEFINES                 += UNICODE WIN32
+DEFINES                 += UNICODE WIN32 _USING_V110_SDK71_
QMAKE_COMPILER_DEFINES  += _MSC_VER=1700 WIN32
QMAKE_CC                = cl
@@ -59,8 +59,8 @@
QMAKE_LFLAGS_RELEASE    = /INCREMENTAL:NO
QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO = /DEBUG /OPT:REF
QMAKE_LFLAGS_DEBUG      = /DEBUG
-QMAKE_LFLAGS_CONSOLE    = /SUBSYSTEM:CONSOLE
-QMAKE_LFLAGS_WINDOWS    = /SUBSYSTEM:WINDOWS
+QMAKE_LFLAGS_CONSOLE    = /SUBSYSTEM:CONSOLE,5.01
+QMAKE_LFLAGS_WINDOWS    = /SUBSYSTEM:WINDOWS,5.01
QMAKE_LFLAGS_EXE        = "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'"
QMAKE_LFLAGS_DLL        = /DLL
QMAKE_LFLAGS_LTCG       = /LTCG
# Recognize spec prefixes.
--- src/3rdparty/webkit/Source/WebCore/WebCore.pri  2013-06-07 09:16:56.000000000 -0400
+++ src/3rdparty/webkit/Source/WebCore/WebCore.pri  2013-09-27 12:20:48.148285400 -0400
@@ -303,7 +303,7 @@
}
# Remove whole program optimizations due to miscompilations
-win32-msvc2005|win32-msvc2008|win32-msvc2010|wince*:{
+win32-msvc2005*|win32-msvc2008*|win32-msvc2010*|win32-msvc2012*|wince*:{
QMAKE_CFLAGS_LTCG -= -GL
QMAKE_CXXFLAGS_LTCG -= -GL

感谢您的精彩教程!

我可以用Qt 4.8.5-1在Win7上成功地重复它(见下面的注释)。

我想补充一些我必须努力解决的问题:

在windows上,需要一个补丁工具。不幸的是,我使用了GnuWin32补丁包,它必须以管理员身份运行。在补丁脚本中,我包含了补丁二进制文件的整个路径。

E:Qtenterprise-src-4.8.5_patch_for_buildpatch-2.5.9-7-binbinpatch --forward --directory=%QT% -p0 --global-reject-file=%SRC%qt4fixes.rej --input=%SRC%qt4fixes.patch

为了允许不同的平台规范在同一台机器上并行,我进行了"源代码外"构建。因此,创建一个新文件夹,例如4.8.5_static-xp_build,启动命令提示符,运行"构建环境"脚本,更改为创建的文件夹,并为qmake(set PATH=%cd%bin;%PATH%)设置PATH。

最后从源文件夹调用configure,例如:

E:Qtqt-everywhere-enterprise-src-4.8.5-1configure -platform win32-msvc2012-static-xp -make nmake -no-phonon -no-qt3support -no-multimedia -no-webkit -no-script -no-scripttools -no-declarative -nomake examples -static

最后一个提示:Qt 4.8 undo补丁脚本不正确,它应该撤消qt4xp.patchqt4fixes.patch,而不是qt4static.patch。。。

注意:我可以编译Qt4.8.5-1,包括xp、静态和静态xp。上一次的Qt演示可以在没有可再发行文件和Qt DLL的WinXP上运行。不幸的是,我没有成功地运行我自己的可执行文件,该文件是用VS2012IDE编译的。用nmake作品编译。。。

相关内容

  • 没有找到相关文章

最新更新