Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can i static build qt project in Visual Studio
Forum Updated to NodeBB v4.3 + New Features

How can i static build qt project in Visual Studio

Scheduled Pinned Locked Moved Unsolved General and Desktop
33 Posts 5 Posters 4.0k Views 2 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 1 Jan 2023, 19:46 last edited by
    #4

    Another way is to build your own version of Qt with all unused features disabled. That requires some work as well.

    Depending on the modules you use, you can shave off some things like unused image/database plugins.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • V Offline
      V Offline
      vandal_op
      wrote on 6 Jan 2023, 13:10 last edited by vandal_op 1 Jun 2023, 13:11
      #5

      he is can run his project with out qt desing

      https://youtu.be/rFHPOZoqzcg?t=91

      but i can't
      i have a few dll error like the qt6core.dll q6widgets.dll qt6network.dll
      i cant run my project with out qt desing

      alt text

      C 1 Reply Last reply 6 Jan 2023, 13:31
      0
      • V vandal_op
        6 Jan 2023, 13:10

        he is can run his project with out qt desing

        https://youtu.be/rFHPOZoqzcg?t=91

        but i can't
        i have a few dll error like the qt6core.dll q6widgets.dll qt6network.dll
        i cant run my project with out qt desing

        alt text

        C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 6 Jan 2023, 13:31 last edited by
        #6

        @vandal_op said in How can i static build qt project in Visual Studio:

        i have a few dll error like the qt6core.dll q6widgets.dll qt6network.dll

        You need to adjust your PATH environment variable so the dlls are found during runtime.

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

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vandal_op
          wrote on 6 Jan 2023, 16:36 last edited by vandal_op 1 Jun 2023, 16:36
          #7

          how can i do?

          where is the dlls? i think i have to found dlls folder and write to this page?
          im right?
          alt text

          C 1 Reply Last reply 6 Jan 2023, 17:01
          0
          • V vandal_op
            6 Jan 2023, 16:36

            how can i do?

            where is the dlls? i think i have to found dlls folder and write to this page?
            im right?
            alt text

            C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 6 Jan 2023, 17:01 last edited by Christian Ehrlicher 1 Jun 2023, 17:01
            #8

            @vandal_op said in How can i static build qt project in Visual Studio:

            how can i do?

            lmgtfy

            where is the dlls?

            In your first post you wrote where you installed your Qt to, so I would start searching in there...

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

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vandal_op
              wrote on 6 Jan 2023, 21:33 last edited by
              #9
              This post is deleted!
              1 Reply Last reply
              0
              • V Offline
                V Offline
                vandal_op
                wrote on 14 Jan 2023, 02:10 last edited by
                #10

                alt text

                i cant build static qt, what is this error?

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vandal_op
                  wrote on 14 Jan 2023, 21:05 last edited by
                  #11

                  any help?

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 14 Jan 2023, 21:23 last edited by
                    #12

                    As you can see in your output you're building for MinGW, not MSVC. Adjust your environment (hint: Visual Studio Command prompt) so cl.exe is properly found by configure.bat/cmake.

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

                    V 1 Reply Last reply 15 Jan 2023, 12:53
                    1
                    • V Offline
                      V Offline
                      vandal_op
                      wrote on 15 Jan 2023, 12:43 last edited by
                      #13

                      i watch this video https://youtu.be/KCH92zvrHas?t=330t
                      and his have a gnuwin32 file in qt src but i dont have
                      and he is using this file for build..

                      https://prnt.sc/dGJM8w4fCtwy

                      https://prnt.sc/8ixug_JUdXLb

                      https://prnt.sc/R_jmzIoEV6Bd

                      1 Reply Last reply
                      0
                      • C Christian Ehrlicher
                        14 Jan 2023, 21:23

                        As you can see in your output you're building for MinGW, not MSVC. Adjust your environment (hint: Visual Studio Command prompt) so cl.exe is properly found by configure.bat/cmake.

                        V Offline
                        V Offline
                        vandal_op
                        wrote on 15 Jan 2023, 12:53 last edited by
                        #14

                        @Christian-Ehrlicher did u have anything info?

                        C 1 Reply Last reply 15 Jan 2023, 13:00
                        0
                        • V vandal_op
                          15 Jan 2023, 12:53

                          @Christian-Ehrlicher did u have anything info?

                          C Offline
                          C Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on 15 Jan 2023, 13:00 last edited by
                          #15

                          @vandal_op said in How can i static build qt project in Visual Studio:

                          did u have anything info?

                          No - I already told you that you have to make sure that configure picks up the msvc compiler and not the MinGW one as you can't mix the two compiler. So clean up your build dir and start over.

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

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            vandal_op
                            wrote on 15 Jan 2023, 15:10 last edited by
                            #16

                            @Christian-Ehrlicher finaly i can build now but not working again..

                            https://prnt.sc/dw5Ji91U6kK6
                            prefix folder is empty

                            https://prnt.sc/n7b1vcGn1pr_

                            1 Reply Last reply
                            0
                            • V Offline
                              V Offline
                              vandal_op
                              wrote on 15 Jan 2023, 15:20 last edited by
                              #17

                              doesnt have jom make file

                              https://prnt.sc/C683RFG_Wa2r

                              1 Reply Last reply
                              0
                              • V Offline
                                V Offline
                                vandal_op
                                wrote on 15 Jan 2023, 19:22 last edited by
                                #18

                                alt text

                                I seriously don't understand qt, I just want to compile as static and I couldn't do it in 3 days..

                                1 Reply Last reply
                                0
                                • Chris KawaC Offline
                                  Chris KawaC Offline
                                  Chris Kawa
                                  Lifetime Qt Champion
                                  wrote on 15 Jan 2023, 19:49 last edited by Chris Kawa
                                  #19

                                  Have 3 folders (you can name them however you want):

                                  /src
                                      //this is where Qt sources are
                                  /build
                                     // this is where you build
                                  /install
                                     //this is where you install
                                  

                                  From start menu open x64 Native Tools Command prompt for VS. You don't need admin privileges.
                                  cd to your build directory (not src!)
                                  In your build directory:
                                  ../src/configure -prefix <full path to install dir> -static -static-runtime <any other options you want>
                                  cmake --build . --parallel
                                  cmake --install .
                                  if you also built debug version then also cmake --install . --config Debug
                                  That's it, 3 or 4 commands.

                                  V 1 Reply Last reply 15 Jan 2023, 21:49
                                  2
                                  • Chris KawaC Chris Kawa
                                    15 Jan 2023, 19:49

                                    Have 3 folders (you can name them however you want):

                                    /src
                                        //this is where Qt sources are
                                    /build
                                       // this is where you build
                                    /install
                                       //this is where you install
                                    

                                    From start menu open x64 Native Tools Command prompt for VS. You don't need admin privileges.
                                    cd to your build directory (not src!)
                                    In your build directory:
                                    ../src/configure -prefix <full path to install dir> -static -static-runtime <any other options you want>
                                    cmake --build . --parallel
                                    cmake --install .
                                    if you also built debug version then also cmake --install . --config Debug
                                    That's it, 3 or 4 commands.

                                    V Offline
                                    V Offline
                                    vandal_op
                                    wrote on 15 Jan 2023, 21:49 last edited by
                                    #20

                                    @Chris-Kawa
                                    alt text
                                    it was running fine but still gave an error

                                    1 Reply Last reply
                                    0
                                    • Chris KawaC Offline
                                      Chris KawaC Offline
                                      Chris Kawa
                                      Lifetime Qt Champion
                                      wrote on 15 Jan 2023, 22:14 last edited by
                                      #21

                                      Read the third line.

                                      V 1 Reply Last reply 15 Jan 2023, 22:29
                                      1
                                      • Chris KawaC Chris Kawa
                                        15 Jan 2023, 22:14

                                        Read the third line.

                                        V Offline
                                        V Offline
                                        vandal_op
                                        wrote on 15 Jan 2023, 22:29 last edited by
                                        #22

                                        @Chris-Kawa

                                        • cd c:/qt-static/build
                                        • c:/qt-static/src/configure -debug-and-release -commercial -confirm-license -static -platform win32-msvc2019 -nomake examples -nomake tests -prefix C:\Qt-Static\install
                                        • cmake --build . --parallel

                                        build success.
                                        alt text
                                        install error
                                        alt text

                                        I think I did all the steps correctly but the result is still like this.

                                        1 Reply Last reply
                                        0
                                        • Chris KawaC Offline
                                          Chris KawaC Offline
                                          Chris Kawa
                                          Lifetime Qt Champion
                                          wrote on 15 Jan 2023, 22:59 last edited by
                                          #23

                                          Don't re-run configure in a directory that you have a failed build in. If a build fails clear the build directory and start over from clean state: empty dir, configure, build, install.
                                          Don't pass -platform win32-msvc2019. Platform is deduced from the environment i.e. the command prompt bat you used. Note that you're building 32bit version. If you want to build 64bit version start the x64 command prompt.
                                          Don't try to build modules you don't need. In the src dir you have directories like this:

                                          qt3d
                                          qt5compat
                                          qtactiveqt
                                          qtcharts
                                          ...
                                          

                                          Each of them is a Qt module. You need qtbase and qttools. Others are optional. Go through the list and for each module you're not planning to use exclude it via parameter of configure. Some of those are also not supported in a static build (you got a message about it in your previous post). Exclude those too. For example to exclude qtwebengine pass -skip qtwebengine. Do that for every module that is not supported or you're not planning to use.

                                          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