1. 程式人生 > 其它 >vs2019編譯Qt4.8.7

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部落格