问题
I'm trying to build Qt 4.8.5 / Qt 5.2.1 using Visual Studio 2012, targeting Windows XP (SDK v7.1a). There are various incompatibilities of the source with SDK v7.1a while compiled with VS2102, so it doesn't work out of the box.
This is to be a canonical question that provides the knowledge necessary to successfully build Qt in such an environment.
回答1:
First of all, the build environment needs to be prepared as below. Caveat emptor: There are variants of this script "out there" that have typos that make it, effectively, a no-op.
@call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
:: The below applies to XP-targeting builds *only*!
@set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
@set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
@set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib;%LIB%
Qt 5.2
First, we note that Qt sources should be kept pristine, so that existing builds aren't broken. We shall not change the existing make specs. Thus:
Create a separate
win32-msvc2012-xp
qmake spec by copying it fromqtbase/mkspecs/win32-msvc2012
. Modify it.Teach configure and qmake makefile about the new qmake spec.
Force bootstrap of configure.exe by creating an empty .gitignore file in qtbase.
The script and the patch below handle the process.
:: 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%\qtbase\mkspecs\%SPEC%-xp
@copy %QT%\qtbase\mkspecs\%SPEC%\qplatformdefs.h %QT%\qtbase\mkspecs\%SPEC%-xp
@copy %QT%\qtbase\mkspecs\%SPEC%\qmake.conf %QT%\qtbase\mkspecs\%SPEC%-xp
@patch --forward --directory=%QT% -p0 --global-reject-file=%SRC%\qt5xp.rej --input=%SRC%\qt5xp.patch
To undo the changes, run the following (the variables must be set as above):
@patch --reverse --directory=%QT% -p0 --global-reject-file=%SRC%\qt5xp-unfix.rej --input=%SRC%\qt5xp.patch
@del %QT%\qtbase\mkspecs\%SPEC%-xp\qplatformdefs.h
@del %QT%\qtbase\mkspecs\%SPEC%-xp\qmake.conf
@rmdir %QT%\qtbase\mkspecs\%SPEC%-xp
@del %QT%\qtbase\.gitignore
The build is then performed by executing:
configure -platform win32-msvc2012-xp
jom (or nmake)
jom install (if doing the build separate from the installation directory)
This make spec also supports static builds (given -static
to configure), with the caveat that the MSVC2012 runtime is still dynamically linked. Support for static MSVC runtime is a subject of another question.
# 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%\src\corelib\global\qglobal.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
回答2:
Qt 5.3 and onwards do not need any additional patches: Just run configure with "-target xp".
You need to set up the right environment though, like suggested in the other answers
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
set PATH=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
set LIB=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include;%LIB%
set CL=/D_USING_V110_SDK71_
(The CL=/D_USING_V110_SDK71_ prevents a lot of warnings from Windows headers).
回答3:
The build environment needs to be prepared as below. Caveat emptor: There are variants of this script "out there" that have typos that make it, effectively, a no-op.
@call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86
:: The below applies to XP-targeting builds *only*!
@set INCLUDE=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Include;%INCLUDE%
@set PATH=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Bin;%PATH%
@set LIB=%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.1A\Lib;%LIB%
Qt 4.8
The following script patches the sources:
:: 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
To undo the changes, run the below:
@patch --reverse --directory=%QT% -p0 --global-reject-file=%SRC%\qt4static-unfix.rej --input=%SRC%\qt4static.patch
@del %QT%\mkspecs\%SPEC%-static\qplatformdefs.h
@del %QT%\mkspecs\%SPEC%-static\qmake.conf
@rmdir %QT%\mkspecs\%SPEC%-static
@del %QT%\mkspecs\%SPEC%-static-xp\qplatformdefs.h
@del %QT%\mkspecs\%SPEC%-static-xp\qmake.conf
@rmdir %QT%\mkspecs\%SPEC%-static-xp
The build is then performed by executing:
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
回答4:
Thanks for this great tutorial!
I could successfully repeat it on Win7 with Qt 4.8.5-1 (see note below).
I want to add some points I have to struggle with:
On windows a patch tool is required. I used GnuWin32 patch package, which has to be run as administrator, unfortunately. In the patch script I included the entire path to the patch binary.
E:\Qt\enterprise-src-4.8.5_patch_for_build\patch-2.5.9-7-bin\bin\patch --forward --directory=%QT% -p0 --global-reject-file=%SRC%\qt4fixes.rej --input=%SRC%\qt4fixes.patch
To allow the different platform specs in parallel on the same machine, I did an "out-of-source" build. Therefore create a new folder, e.g. 4.8.5_static-xp_build
, start a command prompt, run the "build environment" script, change to the created folder and set the PATH for qmake (set PATH=%cd%\bin;%PATH%
).
Finally call the configure from the source folder, in my case for example:
E:\Qt\qt-everywhere-enterprise-src-4.8.5-1\configure -platform win32-msvc2012-static-xp -make nmake -no-phonon -no-qt3support -no-multimedia -no-webkit -no-script -no-scripttools -no-declarative -nomake examples -static
And a final hint: The Qt 4.8 undo patch script is not correct, it is supposed to undo the qt4xp.patch
and the qt4fixes.patch
and not the qt4static.patch
...
Note: I could compile Qt 4.8.5-1 with the variations: xp, static and static-xp. The Qt Demo of the last could be run on a WinXP without redistributables and Qt DLL. Unfortunately I did not succeed to run my own executable, which was compiled with VS2012 IDE. Compiling with nmake works...
来源:https://stackoverflow.com/questions/21840682/how-to-get-qt-4-5-to-build-using-vs2012-while-targeting-windows-xp