Skip to content

Instantly share code, notes, and snippets.

@mikedld
Last active February 18, 2017 12:49
Show Gist options
  • Save mikedld/865433fd91d25e447279bfd304462e1e to your computer and use it in GitHub Desktop.
Save mikedld/865433fd91d25e447279bfd304462e1e to your computer and use it in GitHub Desktop.
Build Qt on Windows
@echo off
setlocal
setlocal enabledelayedexpansion
set R=%CD%
set EXPATVER=2.1.0
set DBUSVER=1.10.6
set ZLIBVER=1.2.8
set OSSLVER=1.0.2g
set CURLVER=7.47.1
set QTVER=5.6.0
rem set C=mingw32
rem set CMAKEGEN="MinGW Makefiles"
rem set MAKECMD=mingw32-make
rem set MAKECMDMP=%MAKECMD% -j8
rem set LIBPREFIX=lib
rem set LIBSUFFIX=.a
rem set QTOPTS=
set C=%TR_CONF%
set CMAKEGEN="NMake Makefiles"
set MAKECMD=nmake
set MAKECMDMP=%MAKECMD%
set LIBPREFIX=
set LIBSUFFIX=.lib
set PREFIX=%R%\3rd-party-%C%
set QTOPTS=-platform win32-msvc2015 -mp -ltcg -opensource -confirm-license
set CMAKEOPTS="-DCMAKE_SHARED_LINKER_FLAGS:STRING=/LTCG /INCREMENTAL:NO /OPT:REF" "-DCMAKE_EXE_LINKER_FLAGS:STRING=/LTCG /INCREMENTAL:NO /OPT:REF"
set EXPATOPTS=-DBUILD_tools=OFF -DBUILD_examples=OFF -DBUILD_tests=OFF -DBUILD_static=OFF
set DBUSOPTS_DBG=-DEXPAT_INCLUDE_DIR:PATH=%PREFIX%\include -DEXPAT_LIBRARY:FILEPATH=%PREFIX%\lib\%LIBPREFIX%expatd%LIBSUFFIX% -DDBUS_BUILD_TESTS=OFF
set DBUSOPTS_REL=-DEXPAT_INCLUDE_DIR:PATH=%PREFIX%\include -DEXPAT_LIBRARY:FILEPATH=%PREFIX%\lib\%LIBPREFIX%expat%LIBSUFFIX% -DDBUS_BUILD_TESTS=OFF
set OSSLOPTS=
set CURLOPTS=-DCMAKE_USE_OPENSSL=ON -DCURL_WINDOWS_SSPI=OFF -DBUILD_CURL_TESTS=OFF -DCURL_DISABLE_DICT=ON -DCURL_DISABLE_GOPHER=ON -DCURL_DISABLE_IMAP=ON -DCURL_DISABLE_SMTP=ON -DCURL_DISABLE_POP3=ON -DCURL_DISABLE_RTSP=ON -DCURL_DISABLE_TFTP=ON -DCURL_DISABLE_TELNET=ON -DCURL_DISABLE_LDAP=ON -DCURL_DISABLE_LDAPS=ON -DENABLE_MANUAL=OFF
md expat-%EXPATVER%\%C%-dbg
pushd expat-%EXPATVER%\%C%-dbg
cmake .. -G %CMAKEGEN% -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_DEBUG_POSTFIX=d %EXPATOPTS% %CMAKEOPTS%
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install/fast
if not !errorlevel! == 0 exit /b 1
popd
md expat-%EXPATVER%\%C%-rel
pushd expat-%EXPATVER%\%C%-rel
cmake .. -G %CMAKEGEN% -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=%PREFIX% %EXPATOPTS% %CMAKEOPTS%
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install/fast
if not !errorlevel! == 0 exit /b 1
popd
md dbus-%DBUSVER%\%C%-dbg
pushd dbus-%DBUSVER%\%C%-dbg
cmake ..\cmake -G %CMAKEGEN% -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_DEBUG_POSTFIX=d %DBUSOPTS_DBG% %CMAKEOPTS%
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install/fast
if not !errorlevel! == 0 exit /b 1
popd
md dbus-%DBUSVER%\%C%-rel
pushd dbus-%DBUSVER%\%C%-rel
cmake ..\cmake -G %CMAKEGEN% -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=%PREFIX% %DBUSOPTS_REL% %CMAKEOPTS%
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install/fast
if not !errorlevel! == 0 exit /b 1
popd
md zlib-%ZLIBVER%\%C%-dbg
pushd zlib-%ZLIBVER%\%C%-dbg
cmake .. -G %CMAKEGEN% -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%PREFIX% %CMAKEOPTS%
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install/fast
if not !errorlevel! == 0 exit /b 1
popd
md zlib-%ZLIBVER%\%C%-rel
pushd zlib-%ZLIBVER%\%C%-rel
cmake .. -G %CMAKEGEN% -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=%PREFIX% %CMAKEOPTS%
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install/fast
if not !errorlevel! == 0 exit /b 1
popd
if "%C%" == "msvc32" (
set OSSLCFG=VC-WIN32
set OSSLPREP=ms\do_nasm.bat
) else (
set OSSLCFG=VC-WIN64A
set OSSLPREP=ms\do_win64a.bat
)
xcopy /E /I /H /R /Y openssl-%OSSLVER% openssl-%OSSLVER%-%C%-dbg
if not !errorlevel! == 0 exit /b 1
pushd openssl-%OSSLVER%-%C%-dbg
patch -p1 -i %R%\openssl-1.0.2d-debug.patch
if not !errorlevel! == 0 exit /b 1
perl Configure --prefix=%PREFIX% debug-%OSSLCFG%
if not !errorlevel! == 0 exit /b 1
%COMSPEC% /c %OSSLPREP%
if not !errorlevel! == 0 exit /b 1
nmake -f ms\ntdll.mak
if not !errorlevel! == 0 exit /b 1
nmake -f ms\ntdll.mak install
if not !errorlevel! == 0 exit /b 1
popd
xcopy /E /I /H /R /Y openssl-%OSSLVER% openssl-%OSSLVER%-%C%-rel
if not !errorlevel! == 0 exit /b 1
pushd openssl-%OSSLVER%-%C%-rel
perl Configure --prefix=%PREFIX% %OSSLCFG%
if not !errorlevel! == 0 exit /b 1
%COMSPEC% /c %OSSLPREP%
if not !errorlevel! == 0 exit /b 1
nmake -f ms\ntdll.mak
if not !errorlevel! == 0 exit /b 1
nmake -f ms\ntdll.mak install
if not !errorlevel! == 0 exit /b 1
popd
md curl-%CURLVER%\%C%-dbg
pushd curl-%CURLVER%\%C%-dbg
cmake .. -G %CMAKEGEN% -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%PREFIX% -DCMAKE_DEBUG_POSTFIX=d %CURLOPTS% %CMAKEOPTS%
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install/fast
if not !errorlevel! == 0 exit /b 1
popd
md curl-%CURLVER%\%C%-rel
pushd curl-%CURLVER%\%C%-rel
cmake .. -G %CMAKEGEN% -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=%PREFIX% %CURLOPTS% %CMAKEOPTS%
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install/fast
if not !errorlevel! == 0 exit /b 1
popd
if not %QTVER% geq 5.0.0 (
md %QTVER%-%C%
xcopy /Y /I /E %QTVER%-src\mkspecs %QTVER%-%C%\mkspecs
)
set PATH=%PREFIX%\bin;%PATH%
set PATH_SAVE=%PATH%
if %QTVER% geq 5.0.0 (
set QTOPTS=%QTOPTS% -prefix %R%\%QTVER%-%C% -force-debug-info ^
-no-opengl ^
-dbus ^
-skip connectivity ^
-skip declarative ^
-skip doc ^
-skip enginio ^
-skip graphicaleffects ^
-skip location ^
-skip multimedia ^
-skip quickcontrols ^
-skip script ^
-skip sensors ^
-skip serialport ^
-skip webchannel ^
-skip webengine ^
-skip websockets ^
-ssl ^
-openssl ^
-system-zlib ^
-qt-pcre ^
-qt-libpng ^
-qt-libjpeg ^
-no-harfbuzz ^
-no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 ^
-no-wmf-backend ^
-no-qml-debug ^
-nomake examples %QTOPTS% -I %PREFIX%\include -L %PREFIX%\lib
rem Up to 5.5.x:
rem -skip quick1 ^
rem -skip webkit ^
rem -skip webkit-examples ^
set PATH=%R%\%QTVER%-%C%-build-dbg\qtbase\lib;%PATH_SAVE:)=^)%
md %QTVER%-%C%-build-dbg
pushd %QTVER%-%C%-build-dbg
%COMSPEC% /c %R%\%QTVER%-src\configure.bat !QTOPTS! -debug OPENSSL_LIBS="libeay32d.lib ssleay32d.lib" ZLIB_LIBS="zlibd.lib"
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install
if not !errorlevel! == 0 exit /b 1
popd
set PATH=%R%\%QTVER%-%C%-build-rel\qtbase\lib;%PATH_SAVE:)=^)%
md %QTVER%-%C%-build-rel
pushd %QTVER%-%C%-build-rel
%COMSPEC% /c %R%\%QTVER%-src\configure.bat !QTOPTS! -release OPENSSL_LIBS="libeay32.lib ssleay32.lib" ZLIB_LIBS="zlib.lib"
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install
if not !errorlevel! == 0 exit /b 1
popd
set PATH=%PATH_SAVE:)=^)%
) else (
%R%\%QTVER%-src\configure.exe -prefix %R%\%QTVER%-%C% -debug-and-release -fast ^
-no-qt3support ^
-no-opengl ^
-dbus ^
-qt-zlib ^
-no-phonon ^
-no-phonon-backend ^
-no-multimedia ^
-no-audio-backend ^
-no-webkit ^
-no-script ^
-no-scripttools ^
-no-declarative ^
-no-declarative-debug ^
-nomake examples -nomake demos %QTOPTS% -I %R%\dbus-%DBUSVER% -I %R%\dbus-%DBUSVER%\%C% -L %R%\dbus-%DBUSVER%\%C%\bin
if not !errorlevel! == 0 exit /b 1
%MAKECMDMP%
if not !errorlevel! == 0 exit /b 1
%MAKECMD% install
if not !errorlevel! == 0 exit /b 1
)
diff -ru 5.5.1-src.orig/qtbase/mkspecs/common/msvc-desktop.conf 5.5.1-src/qtbase/mkspecs/common/msvc-desktop.conf
--- 5.5.1-src.orig/qtbase/mkspecs/common/msvc-desktop.conf 2015-10-13 07:35:32.000000000 +0300
+++ 5.5.1-src/qtbase/mkspecs/common/msvc-desktop.conf 2015-10-18 01:55:40.508885800 +0300
@@ -25,7 +25,7 @@
QMAKE_LEXFLAGS =
QMAKE_YACC = byacc
QMAKE_YACCFLAGS = -d
-QMAKE_CFLAGS = -nologo -Zc:wchar_t
+QMAKE_CFLAGS = -nologo -Zc:wchar_t -EHsc
QMAKE_CFLAGS_WARN_ON = -W3
QMAKE_CFLAGS_WARN_OFF = -W0
QMAKE_CFLAGS_RELEASE = -O2 -MD
diff -ru 5.5.1-src.orig/qtbase/src/dbus/qdbus_symbols.cpp 5.5.1-src/qtbase/src/dbus/qdbus_symbols.cpp
--- 5.5.1-src.orig/qtbase/src/dbus/qdbus_symbols.cpp 2015-10-13 07:35:32.000000000 +0300
+++ 5.5.1-src/qtbase/src/dbus/qdbus_symbols.cpp 2015-10-18 03:01:40.781646400 +0300
@@ -84,14 +84,24 @@
lib->setLoadHints(QLibrary::ExportExternalSymbolsHint); // make libdbus symbols available for apps that need more advanced control over the dbus
triedToLoadLibrary = true;
+#ifdef _DEBUG
+#define DBG_SUFFIX "d"
+#else
+#define DBG_SUFFIX ""
+#endif
+
static int majorversions[] = { 3, 2, -1 };
const QString baseNames[] = {
#ifdef Q_OS_WIN
- QLatin1String("dbus-1"),
+ QLatin1String("dbus-1" DBG_SUFFIX "-3"),
+ QLatin1String("dbus-1" DBG_SUFFIX),
#endif
- QLatin1String("libdbus-1")
+ QLatin1String("libdbus-1" DBG_SUFFIX "-3"),
+ QLatin1String("libdbus-1" DBG_SUFFIX)
};
+#undef DBG_SUFFIX
+
lib->unload();
for (uint i = 0; i < sizeof(majorversions) / sizeof(majorversions[0]); ++i) {
for (uint j = 0; j < sizeof(baseNames) / sizeof(baseNames[0]); ++j) {
diff -ru 5.5.1-src.orig/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp 5.5.1-src/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
--- 5.5.1-src.orig/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp 2015-10-13 07:35:28.000000000 +0300
+++ 5.5.1-src/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp 2015-10-18 01:52:48.133789800 +0300
@@ -588,17 +588,25 @@
pair.first = 0;
pair.second = 0;
+#ifdef _DEBUG
+#define DBG_SUFFIX "d"
+#else
+#define DBG_SUFFIX ""
+#endif
+
// When OpenSSL is built using MSVC then the libraries are named 'ssleay32.dll' and 'libeay32'dll'.
// When OpenSSL is built using GCC then different library names are used (depending on the OpenSSL version)
// The oldest version of a GCC-based OpenSSL which can be detected by the code below is 0.9.8g (released in 2007)
- if (!tryToLoadOpenSslWin32Library(QLatin1String("ssleay32"), QLatin1String("libeay32"), pair)) {
- if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-10"), QLatin1String("libcrypto-10"), pair)) {
- if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-8"), QLatin1String("libcrypto-8"), pair)) {
- tryToLoadOpenSslWin32Library(QLatin1String("libssl-7"), QLatin1String("libcrypto-7"), pair);
+ if (!tryToLoadOpenSslWin32Library(QLatin1String("ssleay32" DBG_SUFFIX), QLatin1String("libeay32" DBG_SUFFIX), pair)) {
+ if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-10" DBG_SUFFIX), QLatin1String("libcrypto-10" DBG_SUFFIX), pair)) {
+ if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-8" DBG_SUFFIX), QLatin1String("libcrypto-8" DBG_SUFFIX), pair)) {
+ tryToLoadOpenSslWin32Library(QLatin1String("libssl-7" DBG_SUFFIX), QLatin1String("libcrypto-7" DBG_SUFFIX), pair);
}
}
}
+#undef DBG_SUFFIX
+
return pair;
}
#else
diff -ru 5.5.1-src.orig/qtimageformats/src/3rdparty/zlib_dependency.pri 5.5.1-src/qtimageformats/src/3rdparty/zlib_dependency.pri
--- 5.5.1-src.orig/qtimageformats/src/3rdparty/zlib_dependency.pri 2015-10-13 07:36:59.000000000 +0300
+++ 5.5.1-src/qtimageformats/src/3rdparty/zlib_dependency.pri 2015-10-18 01:53:36.805581500 +0300
@@ -1,7 +1,10 @@
# zlib dependency satisfied by bundled 3rd party zlib or system zlib
contains(QT_CONFIG, system-zlib) {
unix|mingw: LIBS_PRIVATE += -lz
- else: LIBS += zdll.lib
+ else {
+ isEmpty(ZLIB_LIBS): LIBS += zdll.lib
+ else: LIBS += $$ZLIB_LIBS
+ }
} else {
load(qt_build_paths)
git_build: \
diff -ru 5.5.1-src.orig/qtsvg/src/svg/svg.pro 5.5.1-src/qtsvg/src/svg/svg.pro
--- 5.5.1-src.orig/qtsvg/src/svg/svg.pro 2015-10-13 07:36:57.000000000 +0300
+++ 5.5.1-src/qtsvg/src/svg/svg.pro 2015-10-18 01:54:08.883810900 +0300
@@ -46,7 +46,10 @@
contains(QT_CONFIG, system-zlib) {
if(unix|mingw): LIBS_PRIVATE += -lz
- else: LIBS += zdll.lib
+ else {
+ isEmpty(ZLIB_LIBS): LIBS += zdll.lib
+ else: LIBS += $$ZLIB_LIBS
+ }
} else {
git_build: \
INCLUDEPATH += $$[QT_INSTALL_HEADERS/get]/QtZlib
diff -ru openssl-1.0.2d/ms/do_win64a.bat openssl-1.0.2d-dbg/ms/do_win64a.bat
+++ openssl-1.0.2d\ms\do_nasm.bat 2015-12-03 19:51:01.000000000 +0300
--- openssl-1.0.2d-msvc32-dbg\ms\do_nasm.bat 2016-03-01 23:29:00.231181100 +0300
@@ -4,5 +4,5 @@
perl util\mk1mf.pl dll nasm VC-WIN32 >ms\ntdll.mak
perl util\mk1mf.pl nasm BC-NT >ms\bcb.mak
-perl util\mkdef.pl 32 libeay > ms\libeay32.def
-perl util\mkdef.pl 32 ssleay > ms\ssleay32.def
+perl util\mkdef.pl 32 libeay > ms\libeay32d.def
+perl util\mkdef.pl 32 ssleay > ms\ssleay32d.def
--- openssl-1.0.2d/ms/do_win64a.bat 2015-06-11 17:44:27.000000000 +0300
+++ openssl-1.0.2d-dbg/ms/do_win64a.bat 2015-07-25 17:01:56.743521800 +0300
@@ -15,5 +15,5 @@
perl util\mk1mf.pl VC-WIN64A >ms\nt.mak
perl util\mk1mf.pl dll VC-WIN64A >ms\ntdll.mak
-perl util\mkdef.pl 32 libeay > ms\libeay32.def
-perl util\mkdef.pl 32 ssleay > ms\ssleay32.def
+perl util\mkdef.pl 32 libeay > ms\libeay32d.def
+perl util\mkdef.pl 32 ssleay > ms\ssleay32d.def
diff -ru openssl-1.0.2d/util/mkdef.pl openssl-1.0.2d-dbg/util/mkdef.pl
--- openssl-1.0.2d/util/mkdef.pl 2015-07-09 14:57:15.000000000 +0300
+++ openssl-1.0.2d-dbg/util/mkdef.pl 2015-07-25 17:09:54.054765400 +0300
@@ -1301,9 +1301,9 @@
my $description = "$what $version, $name - http://$http_vendor";
if ($W32)
- { $libname.="32"; }
+ { $libname.="32D"; }
elsif ($W16)
- { $libname.="16"; }
+ { $libname.="16D"; }
elsif ($OS2)
{ # DLL names should not clash on the whole system.
# However, they should not have any particular relationship
diff -ru openssl-1.0.2d/util/pl/VC-32.pl openssl-1.0.2d-dbg/util/pl/VC-32.pl
--- openssl-1.0.2d/util/pl/VC-32.pl 2015-07-09 14:57:15.000000000 +0300
+++ openssl-1.0.2d-dbg/util/pl/VC-32.pl 2015-07-25 16:46:45.727122600 +0300
@@ -3,17 +3,17 @@
# Win64 and WinCE [follow $FLAVOR variable to trace the differences].
#
-$ssl= "ssleay32";
-$crypto="libeay32";
+$ssl= "ssleay32d";
+$crypto="libeay32d";
if ($fips && !$shlib)
{
- $crypto="libeayfips32";
- $crypto_compat = "libeaycompat32.lib";
+ $crypto="libeayfips32d";
+ $crypto_compat = "libeaycompat32d.lib";
}
else
{
- $crypto="libeay32";
+ $crypto="libeay32d";
}
$o='\\';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment