VS2019编译Qt4.8.7

  1. 下载4.8.7源码Index of /archive/qt/4.8/4.8.7

  2. 复制mkspecs\win32-msvc2015mkspecs\win32-msvc2019

  3. 修改qmake.conf

    1. 第2行:2017=>2019

    2. 第4行:2017=>2019

    3. 第12行:_MSC_VER=1920

    4. 第19行:QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t

    5. 第22行:QMAKE_CFLAGS_RELEASE = -O2 -MD -Zi

    /FS(强制同步 PDB 写入) | Microsoft Learn

    /OPT(优化) | Microsoft Learn

    Predefined macros | Microsoft Learn

  4. 修改qmake\Makefile.win32

    1. 第1行:

      !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-msvc2015" || "$(QMAKESPEC)" == "win32-msvc2019" || "$(QMAKESPEC)" == "win32-icc"
      
    2. 第27行:

      !elseif "$(QMAKESPEC)" == "win32-msvc2008" || "$(QMAKESPEC)" == "win32-msvc2010" || "$(QMAKESPEC)" == "win32-msvc2012" || "$(QMAKESPEC)" == "win32-msvc2013" || "$(QMAKESPEC)" == "win32-msvc2015" || "$(QMAKESPEC)" == "win32-msvc2019"
      
  5. 修改tools\configure\configure.pro

    1. 第23行:

      win32-msvc2015: DEFINES += _ALLOW_KEYWORD_MACROS
      win32-msvc2019: DEFINES += _ALLOW_KEYWORD_MACROS
      
  6. 修改tools\configure\configureapp.cpp

    1. 第1379行:

                  qmakeSpec.endsWith("-msvc2015") ||
                  qmakeSpec.endsWith("-msvc2019")) {
      
  7. 修改\src\3rdparty\clucene\src\CLucene\StdHeader.h

    第127行,增加宏定义,消除hash_maphasn_set的警告:

    	#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
    
  8. Configure命令:

    configure -make nmake -static -platform win32-msvc2019 -debug-and-release -opensource -confirm-license -nomake examples -nomake tests -nomake docs -nomake demos -prefix "F:\Code\Library\Qt\Qt4.8.7\4.8.7\msvc2019_86_static" -no-qt3support -no-dbus -no-webkit -no-phonon -no-opengl -qt-zlib -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -no-phonon-backend -no-multimedia -no-script -no-scripttools -qt-style-windowsxp -qt-style-windowsvista -qt-style-plastique -qt-style-cleanlooks -qt-style-motif -no-native-gestures -mp
    

    Configuration Options for Qt | Qt 4.8

  9. 添加bin文件夹到系统路径Path

    F:\Code\Library\Qt\Qt4.8.7\qt-everywhere-opensource-src-4.8.7\bin
    

    Installing Qt for Windows | Qt 4.8

  10. 打开x86 Native Tools Command Prompt for VS 2019,到代码路径F:\Code\Library\Qt\Qt4.8.7\qt-everywhere-opensource-src-4.8.7,编译

    configure -make nmake -static -platform win32-msvc2019 -debug-and-release -opensource -confirm-license -nomake examples -nomake tests -nomake docs -nomake demos -prefix "F:\Code\Library\Qt\Qt4.8.7\4.8.7\msvc2019_86_static" -no-qt3support -no-dbus -no-webkit -no-phonon -no-opengl -qt-zlib -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -no-phonon-backend -no-multimedia -no-script -no-scripttools -qt-style-windowsxp -qt-style-windowsvista -qt-style-plastique -qt-style-cleanlooks -qt-style-motif -no-native-gestures -mp
    nmake && nmake install
    
  11. 参考

    msvc2015 编译 Qt 4.8.7 和 4.8.6 - 流浪侠客 - 博客园 (cnblogs.com)

    Compiling Qt4 HEAD with MSVC 2015 - cstdint errors | Qt Forum

    Building Qt 4.8.7 with Visual Studio 2017? | Qt Forum

    Installing Qt for Windows | Qt 4.8

    qt4.8.7 源码在win7+vs2010环境的x64编译(qt 64位)_木泽八的博客-CSDN博客

    在Visual Studio高版本中使用Qt4,MSVC 2015/2017编译Qt 4.8.7源码_利白的博客-CSDN博客_qt4 vs2017

    district10/qt4-vs2015x64: Qt4 & Visual Studio 2015 (vc14). (github.com)

    sandym/qt-patches: Patches to some release versioin of Qt I use (github.com)

    在 VS2015 中使用 Qt4 - 简书 (jianshu.com)

    Installation | Qt 4.8

    Qt 4.8

    Known Issues | Qt 4.8

    win10下vs2010编译64位qt4.8.7_YngSo的博客-CSDN博客

    VS2019 配置 qt4.8.7_Nrtyck的博客-CSDN博客

posted on 2022-11-29 13:19  OctoberKey  阅读(457)  评论(0编辑  收藏  举报

导航