Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Problems encountered when I use vs2022+qt6 static compilation
Forum Updated to NodeBB v4.3 + New Features

Problems encountered when I use vs2022+qt6 static compilation

Scheduled Pinned Locked Moved Solved Qt 6
19 Posts 6 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kkoehneK Offline
    kkoehneK Offline
    kkoehne
    Moderators
    wrote on last edited by
    #2

    @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

    Question 1:When I try to set /mt to generate release x64 in c++, I get the following prompt:
    'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
    But I have modified 6.3.0\Src\qtbase\mkspecs\common\msvc-desktop.conf

    Note that Qt itself is not built with qmake, but CMake. To build Qt itself with a static runtime (/mt), pass '-static-runtime' to configure.

    Question 2:When I use /md, the generated exe size reaches 14m. Is this normal? How can I further reduce its size?

    I assume you're talking about 14 MB? This obviously largely depends on which Qt modules you use ... You might furthermore reduce the size by diabling features (look into -list-features argument for configure). Anyhow, this can open a can of worms, and only few features have a noticeable impact...

    Director R&D, The Qt Company

    I 1 Reply Last reply
    1
    • kkoehneK kkoehne

      @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

      Question 1:When I try to set /mt to generate release x64 in c++, I get the following prompt:
      'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
      But I have modified 6.3.0\Src\qtbase\mkspecs\common\msvc-desktop.conf

      Note that Qt itself is not built with qmake, but CMake. To build Qt itself with a static runtime (/mt), pass '-static-runtime' to configure.

      Question 2:When I use /md, the generated exe size reaches 14m. Is this normal? How can I further reduce its size?

      I assume you're talking about 14 MB? This obviously largely depends on which Qt modules you use ... You might furthermore reduce the size by diabling features (look into -list-features argument for configure). Anyhow, this can open a can of worms, and only few features have a noticeable impact...

      I Offline
      I Offline
      injertao
      wrote on last edited by
      #3

      @kkoehne Thank you for your reply
      I used -static
      see:-static -debug-and-release -mp -opensource -confirm-license -optimize-size
      b7c95207-e616-4f46-b4dd-6e0c1942397e-image.png

      I can compile static normally, but when I change C++ to /MT, I get an error:

      'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'

      Christian EhrlicherC 1 Reply Last reply
      0
      • I injertao

        @kkoehne Thank you for your reply
        I used -static
        see:-static -debug-and-release -mp -opensource -confirm-license -optimize-size
        b7c95207-e616-4f46-b4dd-6e0c1942397e-image.png

        I can compile static normally, but when I change C++ to /MT, I get an error:

        'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

        I used -static

        '-static-runtime'

        These are two different kind of things. You compile with a static runtime (MT) therefore you also have to compile Qt with a static runtime as @kkoehne told you.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        I 1 Reply Last reply
        3
        • Christian EhrlicherC Christian Ehrlicher

          @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

          I used -static

          '-static-runtime'

          These are two different kind of things. You compile with a static runtime (MT) therefore you also have to compile Qt with a static runtime as @kkoehne told you.

          I Offline
          I Offline
          injertao
          wrote on last edited by
          #5

          @Christian-Ehrlicher I successfully built QT using -static -static runtime, and vs2022 successfully generated a simple exe, but this exe cannot run normally on win7 x64,


          QtWidgetsApplication1. exe - System Error


          The program can't start because api-ms-win-shcore-scaling-l1-1-1. dll is missing from your computer. Try reinstalling the program to fix this problem.


          OK


          How can I further solve this problem? I hope my exe can run without any explicit DLL.

          thanks u

          kkoehneK 1 Reply Last reply
          0
          • I Offline
            I Offline
            injertao
            wrote on last edited by injertao
            #6

            @kkoehne @Christian-Ehrlicher
            Please help me.

            SET VS_ENVIRONMENT="C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat"
            SET SRC_DIR="C:\Work\Qt\6.3.0\Src"
            SET BUILD_DIR="C:\Work\Qt\6.3.0\Build"
            SET INSTALL_DIR="C:\Work\Qt\6.3.0\msvc2019_64_static_size"
            SET CONFIGURE_OPTIONS=-debug-and-release -mp -opensource -confirm-license -static -static-runtime -optimize-size

            call %VS_ENVIRONMENT%
            mkdir %BUILD_DIR%
            mkdir %INSTALL_DIR%
            cd %BUILD_DIR%
            call %SRC_DIR%\configure -prefix %INSTALL_DIR% %CONFIGURE_OPTIONS%
            cmake --build . --parallel
            cmake --install .
            cmake --install . --config Debug
            cd %INSTALL_DIR%
            rmdir %BUILD_DIR% /Q /S
            pause

            configure return:
            38e0f412-d319-4662-8efb-8eec1178a872-image.png

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #7

              Hi, the error "No space left on device" means your C: drive is full :-(
              Try removing some stuff

              I 1 Reply Last reply
              0
              • hskoglundH hskoglund

                Hi, the error "No space left on device" means your C: drive is full :-(
                Try removing some stuff

                I Offline
                I Offline
                injertao
                wrote on last edited by
                #8

                @hskoglund I'm stupid, but my C drive has 100GB, isn't that enough?

                JonBJ 1 Reply Last reply
                0
                • I injertao

                  @hskoglund I'm stupid, but my C drive has 100GB, isn't that enough?

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #9

                  @injertao
                  Yeah, that really should be plenty :) Re-verify you still have that much space left. It's possible that error message is "misleading". Can you manage to copy the file in question from/to the exact paths in the message? Is there some issue creating the destination path?

                  I 1 Reply Last reply
                  0
                  • I injertao

                    @Christian-Ehrlicher I successfully built QT using -static -static runtime, and vs2022 successfully generated a simple exe, but this exe cannot run normally on win7 x64,


                    QtWidgetsApplication1. exe - System Error


                    The program can't start because api-ms-win-shcore-scaling-l1-1-1. dll is missing from your computer. Try reinstalling the program to fix this problem.


                    OK


                    How can I further solve this problem? I hope my exe can run without any explicit DLL.

                    thanks u

                    kkoehneK Offline
                    kkoehneK Offline
                    kkoehne
                    Moderators
                    wrote on last edited by
                    #10

                    @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

                    I successfully built QT using -static -static runtime, and vs2022 successfully generated a simple exe, but this exe cannot run normally on win7 x64

                    Please note Qt 6 only supports Windows 10.

                    Director R&D, The Qt Company

                    I 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @injertao
                      Yeah, that really should be plenty :) Re-verify you still have that much space left. It's possible that error message is "misleading". Can you manage to copy the file in question from/to the exact paths in the message? Is there some issue creating the destination path?

                      I Offline
                      I Offline
                      injertao
                      wrote on last edited by
                      #11

                      @JonB Thanks, I'm rebuilding(This may take up to 2 hours), but my problem is still that I can't run my EXE on Windows 7 X64 and shrink it perfectly

                      1 Reply Last reply
                      0
                      • kkoehneK Offline
                        kkoehneK Offline
                        kkoehne
                        Moderators
                        wrote on last edited by
                        #12

                        @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

                        SET CONFIGURE_OPTIONS=-debug-and-release -mp -opensource -confirm-license -static -static-runtime -optimize-size
                        [...]
                        @hskoglund I'm stupid, but my C drive has 100GB, isn't that enough?

                        Well, you're asking for a static debug build + static release build of all of Qt. If you combine static with debug, executable sizes add up quite fast :)

                        Do you really need the debug build?

                        Director R&D, The Qt Company

                        I 1 Reply Last reply
                        0
                        • kkoehneK kkoehne

                          @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

                          I successfully built QT using -static -static runtime, and vs2022 successfully generated a simple exe, but this exe cannot run normally on win7 x64

                          Please note Qt 6 only supports Windows 10.

                          I Offline
                          I Offline
                          injertao
                          wrote on last edited by
                          #13

                          @kkoehne thanks
                          What is the last version to support Windows 7 x64?
                          I have a strange problem.
                          96db3558-b487-473c-ab2a-32276b20a498-image.png

                          I have 100GB on my hard drive

                          1 Reply Last reply
                          0
                          • kkoehneK Offline
                            kkoehneK Offline
                            kkoehne
                            Moderators
                            wrote on last edited by
                            #14

                            @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

                            What is the last version to support Windows 7 x64?

                            Qt 5.15

                            have 100GB on my hard drive

                            Check your file system. Is there enough space left?

                            Director R&D, The Qt Company

                            1 Reply Last reply
                            0
                            • kkoehneK kkoehne

                              @injertao said in Problems encountered when I use vs2022+qt6 static compilation:

                              SET CONFIGURE_OPTIONS=-debug-and-release -mp -opensource -confirm-license -static -static-runtime -optimize-size
                              [...]
                              @hskoglund I'm stupid, but my C drive has 100GB, isn't that enough?

                              Well, you're asking for a static debug build + static release build of all of Qt. If you combine static with debug, executable sizes add up quite fast :)

                              Do you really need the debug build?

                              I Offline
                              I Offline
                              injertao
                              wrote on last edited by
                              #15

                              @kkoehne thanks
                              My operation is in VMWARE, there is only one C drive, I am sure it has 113GB left

                              1 Reply Last reply
                              0
                              • hskoglundH Offline
                                hskoglundH Offline
                                hskoglund
                                wrote on last edited by
                                #16

                                Hi, iperhaps iit is because your host OS has no space left (even thougjh your C: drive inside VMWare is ok)
                                This can happen when you tell VMWare to dynamically allocate space for the C: drive (i.e. not a fixed size C:)

                                I 1 Reply Last reply
                                0
                                • cristian-adamC Offline
                                  cristian-adamC Offline
                                  cristian-adam
                                  wrote on last edited by
                                  #17

                                  Note that Qt6 applications, even compiled statically, won't run on Windows 7.

                                  If you really want to achieve this, you need to patch Qt6, see details at https://forum.qt.io/topic/133002/qt-creator-6-0-1-and-qt-6-2-2-running-on-windows-7

                                  If you run out of disk space, you can set the NTFS compression flag of your build directory.

                                  I 1 Reply Last reply
                                  1
                                  • hskoglundH hskoglund

                                    Hi, iperhaps iit is because your host OS has no space left (even thougjh your C: drive inside VMWare is ok)
                                    This can happen when you tell VMWare to dynamically allocate space for the C: drive (i.e. not a fixed size C:)

                                    I Offline
                                    I Offline
                                    injertao
                                    wrote on last edited by
                                    #18

                                    @hskoglund
                                    I confirm that the disk capacity of the host is sufficient

                                    thanks

                                    1 Reply Last reply
                                    0
                                    • cristian-adamC cristian-adam

                                      Note that Qt6 applications, even compiled statically, won't run on Windows 7.

                                      If you really want to achieve this, you need to patch Qt6, see details at https://forum.qt.io/topic/133002/qt-creator-6-0-1-and-qt-6-2-2-running-on-windows-7

                                      If you run out of disk space, you can set the NTFS compression flag of your build directory.

                                      I Offline
                                      I Offline
                                      injertao
                                      wrote on last edited by
                                      #19

                                      @cristian-adam
                                      Thank you, I will make further Chan

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved