Build a static Qt5.7.1 for Windows using MSVC2013

Build a static Qt5.7.1 for Windows using MSVC2013

1. Download and extract Qt source code to this path, or you can use the source code from the online installer (in this case you have to choose to download source code during installation):

C:\Qt\Msvc\Src-5.7.1

2. Create folder C:\Qt\Msvc\Qt5.7.1_static
3. Go to C:\Qt\Msvc\Src-5.7.1\qtbase\mkspecs\common
and change msvc-desktop.conf like this (change all MD to MT to remove dependency on msvc dlls):
Initial values:

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

Should be changed to:

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

4. Using MSVC2013 Developer Command Line tools, running as admin, Configure using following command:
(first change directory to here using “cd” command : C:\Qt\Msvc\Src-5.7.1)
Configure:

configure.bat -static -debug-and-release -opensource -prefix "C:\Qt\Msvc\Qt5.7.1_static" -c++std c++11 -mp -qt-sql-sqlite -plugin-sql-sqlite -opengl es2 -opengl desktop -platform win32-msvc2013 -qt-zlib -qt-libjpeg -qt-libpng -qt-sql-odbc -dbus-linked -dbus-runtime -no-qml-debug -qt-style-windows -qt-style-fusion -nomake examples -make libs -make tools -qt-pcre

(Notice that the parameter -platform win32-msvc2013 should be set according to the compiler you are using)
(Also note that you can add or remove parts and pieces of the libraries you are building by adding or removing parameters above, for example I always use ODBC so I add -qt-sql-odbc parameter but you might want to remove it if you don't need it.)
5. Run nmake (or JOM if you have it --  jom -j 4
6. run nmake install (jom install -j 4)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值