Results 1 to 9 of 9

Thread: Qt5 and Visual Studion 2022

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,233
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt5 and Visual Studion 2022

    OK, here's what you do to build an out-of-source Qt on Windows with VS 2022:

    0 - Download the Qt 5 source distribution and unzip it where you want it to be.
    1 - Open a Visual Studio command prompt window. (Start Menu: Programs -> Visual Studio 2022 -> Visual Studio Tools -> Developer Command Prompt)
    2 - CD to your Qt5 "src" directory, then go up one level.
    3 - At this level, create a "build" directory and CD to it
    4 - Run "..\src\configure -opensource" and reply "y" to the prompt when asked to accept the open source terms.
    5 - When this completes, run "nmake" from within the build directory. It will take an hour or more to build Qt.
    6 - Optionally, run "nmake install" after this finishes. By default, this will install the binaries to a directory under C:\Qt. There is probably a configure option to change this location; check the Qt documentation.

    If you get an error when running the configure script:

    "msvc-version.conf loaded but QMAKE_MSC_VER isn't set"
    then open the file in the src\qtbase\mkspecs\common\msvc-version.conf and add this line at the top of the file (above where you will see the error message):

    Qt Code:
    1. QMAKE_MSC_VER = 1920
    To copy to clipboard, switch view to plain text mode 

    (This is for my Qt 5.14.2 distribution. A later Qt5 distribution could have support for Visual Studio 2022 already - look towards the bottom of this file for the last entry of the form below that has something like this:

    Qt Code:
    1. greaterThan(QMAKE_MSC_VER, 1909) {
    2. # Visual Studio 2017 (15.0) / Visual C++ 19.10 and up
    3. MSVC_VER = 15.0
    4. COMPAT_MKSPEC = win32-msvc2017
    5. QMAKE_CXXFLAGS += -Zc:referenceBinding
    6.  
    7. # Only Visual Studio 2017 version 15.3 / Visual C++ 19.11 & up have support
    8. # for AVX-512. We enable the switches anyway and let configure check if they
    9. # work.
    10. QMAKE_CFLAGS_AVX512F = -arch:AVX512
    11. QMAKE_CFLAGS_AVX512ER = -arch:AVX512
    12. QMAKE_CFLAGS_AVX512CD = -arch:AVX512
    13. QMAKE_CFLAGS_AVX512PF = -arch:AVX512
    14. QMAKE_CFLAGS_AVX512DQ = -arch:AVX512
    15. QMAKE_CFLAGS_AVX512BW = -arch:AVX512
    16. QMAKE_CFLAGS_AVX512VL = -arch:AVX512
    17. QMAKE_CFLAGS_AVX512IFMA = -arch:AVX512
    18. QMAKE_CFLAGS_AVX512VBMI = -arch:AVX512
    19.  
    20. # For now permissive fails as soon as UWP API comes into play. In qtbase this
    21. # API is used in direct2d, but also in multimedia, positioning and sensors.
    22. # We can try again with a later version of Visual Studio.
    23. # QMAKE_CXXFLAGS_STRICTCXX = -permissive-
    24.  
    25. # MSVC partially supports the following, but '__cplusplus' definition is set
    26. # as for C++98 until MSVC fully conforms with C++14, see
    27. # https://developercommunity.visualstudio.com/content/problem/139261/msvc-incorrectly-defines-cplusplus.html
    28. # Support became available in MSVC 2017 15.7:
    29. greaterThan(QMAKE_MSC_VER, 1913) {
    30. QMAKE_CXXFLAGS += -Zc:__cplusplus
    31. QMAKE_CXXFLAGS_CXX14 = -std:c++14
    32. QMAKE_CXXFLAGS_CXX1Z = -std:c++17
    33. }
    34. }
    To copy to clipboard, switch view to plain text mode 

    In my case (Qt 5.14.2), the last entry is the above, with an entry after that that references the VS 2019 version and modifies a couple of the variables defined above:

    Qt Code:
    1. greaterThan(QMAKE_MSC_VER, 1919) {
    2. # Visual Studio 2019 (16.0) / Visual C++ 19.20 and up
    3. MSVC_VER = 16.0
    4. QMAKE_CXXFLAGS_CXX2A = -std:c++latest
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

    Setting QMAKE_MSVC_VER to 1920 will ensure that at least the VS 2019 compiler will be used with the latest C++ version.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  2. The following user says thank you to d_stranz for this useful post:

    bleriot13 (8th March 2023)

Similar Threads

  1. Replies: 2
    Last Post: 5th March 2021, 22:57
  2. Using Qt 5.4.1 Visual Studio 2013 libs in Visual Studio 2010
    By ^NyAw^ in forum Installation and Deployment
    Replies: 0
    Last Post: 6th March 2015, 10:20
  3. ms visual c++ compile without ms visual studio
    By zzz9 in forum General Programming
    Replies: 2
    Last Post: 12th August 2012, 20:29
  4. How to find if Visual Studion 2008 installed
    By sawerset in forum Newbie
    Replies: 1
    Last Post: 7th December 2008, 18:28
  5. qt in Visual Studion
    By sanjayk in forum Qt Programming
    Replies: 2
    Last Post: 25th November 2008, 09:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.