一、源码下载
1、下载python与Perl,尽量使用最新版,并加入到系统PATH环境变量中
2、QT源码下载地址:http://download.qt.io/archive/qt/
3、开启vs环境变量:
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvars32.bat"
二、编译静态库
编译静态库,需要修改运行时库,如下
路径:qtbase\mkspecs\common\msvc-desktop.conf
QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -MD -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MDd
变为:
QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MTd
然后执行下面的配置,最后nmake 和nmake install
configure -confirm-license -opensource -platform win32-msvc -debug-and-release -static -static-runtime \
-force-debug-info -opengl dynamic -prefix "../msvc2017_static" -qt-sqlite -qt-pcre -qt-zlib -qt-libpng \
-qt-libjpeg -opengl desktop -qt-freetype -nomake tests -no-compile-examples -nomake examples
三、编译动态库
1、编译debug版
configure -confirm-license -opensource -platform win32-msvc -debug -shared -force-debug-info \
-opengl dynamic -prefix "../msvc2017_debug" -qt-sqlite -qt-pcre -qt-zlib -qt-libpng -qt-libjpeg \
-opengl desktop -qt-freetype -nomake tests -no-compile-examples -nomake examples
debug版无法使用VC-LTL,所以不需要加载,直接nmake然后nmake install 就行了。
2、编译release版
configure -confirm-license -opensource -platform win32-msvc -release -shared -force-debug-info \
-opengl dynamic -prefix "../msvc2017_release" -qt-sqlite -qt-pcre -qt-zlib -qt-libpng -qt-libjpeg \
-opengl desktop -qt-freetype -nomake tests -no-compile-examples -nomake examples
加载VC-LTL,下载地址:https://gitee.com/Chuyu-Team/VC-LTL
"D:\\cpp\\VC_LTL\\VC-LTL helper for nmake.cmd"
再nmake然后nmake install 就行了。