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 to build static Qt 6.4 for Windows?
Forum Updated to NodeBB v4.3 + New Features

How to build static Qt 6.4 for Windows?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.9k 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.
  • R Offline
    R Offline
    rnayabed
    wrote on last edited by
    #1

    I am a noob, so please excuse ^^

    I followed this tutorial here since I was not able to find a tutorial within Qt documentation:
    https://decovar.dev/blog/2018/02/17/build-qt-statically/

    I ran this command to build qt:

    configure.bat -static -release -no-pch -prefix "d:\path\to\qt\5.15.2-static" -skip qtwebengine -nomake tests -nomake examples
    

    However, it seems the above method is meant only for Qt 5, not 6. when i follow the above method i get this error after running the built app:
    3e97673c-72e9-45dd-bca9-d32fb560bc36-image.png

    Is there any resource/tutorial on how to build Qt 6.4.2 static? Thanks.

    C 1 Reply Last reply
    0
    • R rnayabed

      I am a noob, so please excuse ^^

      I followed this tutorial here since I was not able to find a tutorial within Qt documentation:
      https://decovar.dev/blog/2018/02/17/build-qt-statically/

      I ran this command to build qt:

      configure.bat -static -release -no-pch -prefix "d:\path\to\qt\5.15.2-static" -skip qtwebengine -nomake tests -nomake examples
      

      However, it seems the above method is meant only for Qt 5, not 6. when i follow the above method i get this error after running the built app:
      3e97673c-72e9-45dd-bca9-d32fb560bc36-image.png

      Is there any resource/tutorial on how to build Qt 6.4.2 static? Thanks.

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @rnayabed You need to deploy the DLL that provides std::pmr::get_default_resource(), or build that into your static binary.

      R 1 Reply Last reply
      0
      • C ChrisW67

        @rnayabed You need to deploy the DLL that provides std::pmr::get_default_resource(), or build that into your static binary.

        R Offline
        R Offline
        rnayabed
        wrote on last edited by
        #3

        @ChrisW67 How would I do that? Thanks

        veryqtpersonV 1 Reply Last reply
        0
        • R rnayabed

          @ChrisW67 How would I do that? Thanks

          veryqtpersonV Offline
          veryqtpersonV Offline
          veryqtperson
          wrote on last edited by veryqtperson
          #4

          It looks like you've built Qt with MinGW and then used CMake to build your project. I had a similar problem recently where building with qmake produced an executable that was able to launch without requiring any DLLs, while CMake-produced executable was complaining about missing DLLs, similar to how yours does.

          So if you are in fact using CMake, my bet is that you need to do something like this in your project:

          set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
          

          Looking at the std::pmr::get_default_resource symbol, it seems that your application is missing exactly that - a C++ runtime. And it could also be that you need to enforce C++17 standard in your project.

          It is also possible that you'll get more DLLs erorrs after that, like missing zstd DLL for example. In that case you'll need to link to those too (with target_link_libraries() in case of CMake).

          sierdzioS 1 Reply Last reply
          0
          • veryqtpersonV veryqtperson

            It looks like you've built Qt with MinGW and then used CMake to build your project. I had a similar problem recently where building with qmake produced an executable that was able to launch without requiring any DLLs, while CMake-produced executable was complaining about missing DLLs, similar to how yours does.

            So if you are in fact using CMake, my bet is that you need to do something like this in your project:

            set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
            

            Looking at the std::pmr::get_default_resource symbol, it seems that your application is missing exactly that - a C++ runtime. And it could also be that you need to enforce C++17 standard in your project.

            It is also possible that you'll get more DLLs erorrs after that, like missing zstd DLL for example. In that case you'll need to link to those too (with target_link_libraries() in case of CMake).

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            Here is a configure line I'm using to build Qt 6.4.3 statically on Windows (and please remember to respect the license! Static builds usually mean commercial license of Qt!):

            ..\qt-everywhere-src-6.4.3\configure.bat -static -static-runtime  -plugin-manifests -no-openssl -schannel -c++std c++20 -dbus-runtime -confirm-license -release -nomake examples -nomake tests -prefix ..\6.4.3 -no-icu -no-glib -qt-doubleconversion -qt-pcre -qt-zlib -qt-freetype -qt-harfbuzz -qt-libpng -qt-libjpeg -qt-sqlite -qt-tiff -qt-webp -skip qtcoap -skip qtopcua -skip qtscxml -skip qtwebengine -skip qt3d -skip qtconnectivity -skip qtlanguageserver -skip qtpositioning -skip qtsensors -skip qt5compat -skip qtdatavis3d -skip qtlottie -skip qtquick3d -skip qtserialbus -skip qtwebview -skip qtactiveqt -skip qtquick3dphysics -skip qtserialport -skip qtquicktimeline -skip qtwayland -skip qtcharts -skip qthttpserver -skip qtremoteobjects -skip qtspeech -skip qtwebchannel -skip qtmultimedia
            
            cmake --build . --parallel
            
            cmake --install .
            

            Mind you, I am using MSVC to build, I am not sure if the same will work for MinGW.

            (Z(:^

            1 Reply Last reply
            1

            • Login

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