Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to configure QT6 static?
Forum Update on Monday, May 27th 2025

How to configure QT6 static?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
15 Posts 6 Posters 2.5k Views
  • 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.
  • P Offline
    P Offline
    Peal Wang
    wrote on last edited by
    #5

    I use cmake directly and successful. This is my configure:

    cmake -S ../.. ^
      -G Ninja ^
      -DCMAKE_BUILD_TYPE=Debug ^
      -DBUILD_SHARED_LIBS=OFF ^
      -DFEATURE_static_runtime=ON ^
      -DCMAKE_INSTALL_PREFIX="C:/Library/QT/6.8.1/VS2019/x64-debug-static" ^
      -DBUILD_qtdoc=OFF ^
      -DBUILD_qtwebengine=OFF ^
      -DBUILD_qtwebview=OFF ^
      -DBUILD_qtwayland=OFF ^
      -DBUILD_WITH_PCH=OFF ^
      -DQT_INTERNAL_CALLED_FROM_CONFIGURE:BOOL=TRUE ^
      -DQT_QMAKE_TARGET_MKSPEC=win32-msvc ^
      -DCMAKE_C_COMPILER=cl ^
      -DCMAKE_CXX_COMPILER=cl ^
      -DQT_BUILD_TESTS=FALSE ^
      -DQT_BUILD_EXAMPLES=FALSE ^
      -DFEATURE_cxx20=OFF ^
      -DFEATURE_cxx2b=OFF ^
      -DFEATURE_ssl=ON ^
      -DINPUT_openssl=linked ^
      -DFEATURE_system_zlib=ON ^
      -DFEATURE_system_sqlite=ON ^
      -DINPUT_libpng=system ^
      -DINPUT_libjpeg=system ^
      -DINPUT_freetype=system ^
      -DINPUT_harfbuzz=system ^
      -DINPUT_pcre=system ^
      -DINPUT_doubleconversion=system ^
      -DINPUT_webp=system ^
      -DINPUT_tiff=system ^
      -DFEATURE_icu=ON ^
      -DFEATURE_gif=ON ^
      -DFEATURE_ico=ON ^
      -DFEATURE_vulkan=OFF ^
      -DFEATURE_xcb=OFF ^
      -DFEATURE_egl=OFF ^
      -DFEATURE_libudev=OFF ^
      -DFEATURE_slog2=OFF ^
      -DFEATURE_dbus=OFF ^
      -DCMAKE_CXX_STANDARD=17 ^
      -DCMAKE_C_STANDARD=11 ^
      -DCMAKE_EXE_LINKER_FLAGS="brotlicommon.lib brotlidec.lib brotlienc.lib bz2d.lib deflatestatic.lib libsharpyuv.lib lzma.lib rpcrt4.lib usp10.lib"
    

    The key should be to specify libs using CMAKE_EXE_LINKER_FLAGS

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rparon
      wrote on last edited by
      #6

      is someone static compiling 6.8.2 in Windows 11 with VS2022 ?
      I run the command

      configure.bat -platform win32-msvc -release -static -static-runtime -prefix C:\Qt/Qt6.8.2/64 -commercial -confirm-license -plugin-manifests -nomake examples -nomake tests

      I am able to compile version 6.8.1 but with version 6.8.2 I get many warnings and finally it compiles about 12000 lines (6.8.2) or source instead of about 18000 (6.8.1)

      jsulmJ 1 Reply Last reply
      0
      • R rparon

        is someone static compiling 6.8.2 in Windows 11 with VS2022 ?
        I run the command

        configure.bat -platform win32-msvc -release -static -static-runtime -prefix C:\Qt/Qt6.8.2/64 -commercial -confirm-license -plugin-manifests -nomake examples -nomake tests

        I am able to compile version 6.8.1 but with version 6.8.2 I get many warnings and finally it compiles about 12000 lines (6.8.2) or source instead of about 18000 (6.8.1)

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #7

        @rparon said in How to configure QT6 static?:

        I am able to compile version 6.8.1 but with version 6.8.2 I get many warnings and finally it compiles about 12000 lines (6.8.2) or source instead of about 18000 (6.8.1)

        So, does the build succeed or not? The fact that it compiles less files can be related to what modules where activated when running configure script.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rparon
          wrote on last edited by
          #8

          thank you for the comment,
          yes, despite the many warnings (also requesting the folder of CLang) the compling process terminates and I able to run
          ninja install
          however whenI try to compile my project (QML + C++) the linking process terminates showing a strange error, see below ,cannot open input file '(.obj'

          [ 91%] Linking CXX static library myproject.lib
          [ 92%] Built target myproject
          [ 92%] Built target myprojectx_autogen_timestamp_deps
          [ 93%] Automatic MOC for target myprojectx
          [ 93%] Built target myprojectx_autogen
          [ 94%] Running AUTOMOC file extraction for target myprojectx
          [ 94%] Running moc --collect-json for target myprojectx
          [ 97%] Building CXX object CMakeFiles/myprojectx.dir/myprojectx_autogen/mocs_compilation.cpp.obj
          [ 97%] Building CXX object CMakeFiles/myprojectx.dir/myprojectx/myprojectxx.cpp.obj
          mocs_compilation.cpp
          myprojectxx.cpp
          [ 98%] Linking CXX shared library myprojectx.dll

          ....

          failed (exit code 1181) with the following output:
          LINK : fatal error LNK1181: cannot open input file '(.obj'
          jom: E:\bin\ppp\windows\64\CMakeFiles\myprojectx.dir\build.make [myprojectx.dll] Error 2
          jom: E:\bin\ppp\windows\64\CMakeFiles\Makefile2 [CMakeFiles\myprojectx.dir\all] Error 2
          jom: E:\bin\ppp\windows\64\Makefile [all] Error 2
          01:47:28: The process "C:\CMake\bin\cmake.exe" exited with code 2.
          01:47:28: Error while building/deploying project myprojectx (kit: Qt 6.8.1(64))
          01:47:28: When executing step "Build"
          01:47:28: Elapsed time: 00:29.

          which seems strange as I am unable to locate a file name with this string / substring '(.obj' inside....

          do you have any clue to solve this problem ?

          jsulmJ 1 Reply Last reply
          0
          • R rparon

            thank you for the comment,
            yes, despite the many warnings (also requesting the folder of CLang) the compling process terminates and I able to run
            ninja install
            however whenI try to compile my project (QML + C++) the linking process terminates showing a strange error, see below ,cannot open input file '(.obj'

            [ 91%] Linking CXX static library myproject.lib
            [ 92%] Built target myproject
            [ 92%] Built target myprojectx_autogen_timestamp_deps
            [ 93%] Automatic MOC for target myprojectx
            [ 93%] Built target myprojectx_autogen
            [ 94%] Running AUTOMOC file extraction for target myprojectx
            [ 94%] Running moc --collect-json for target myprojectx
            [ 97%] Building CXX object CMakeFiles/myprojectx.dir/myprojectx_autogen/mocs_compilation.cpp.obj
            [ 97%] Building CXX object CMakeFiles/myprojectx.dir/myprojectx/myprojectxx.cpp.obj
            mocs_compilation.cpp
            myprojectxx.cpp
            [ 98%] Linking CXX shared library myprojectx.dll

            ....

            failed (exit code 1181) with the following output:
            LINK : fatal error LNK1181: cannot open input file '(.obj'
            jom: E:\bin\ppp\windows\64\CMakeFiles\myprojectx.dir\build.make [myprojectx.dll] Error 2
            jom: E:\bin\ppp\windows\64\CMakeFiles\Makefile2 [CMakeFiles\myprojectx.dir\all] Error 2
            jom: E:\bin\ppp\windows\64\Makefile [all] Error 2
            01:47:28: The process "C:\CMake\bin\cmake.exe" exited with code 2.
            01:47:28: Error while building/deploying project myprojectx (kit: Qt 6.8.1(64))
            01:47:28: When executing step "Build"
            01:47:28: Elapsed time: 00:29.

            which seems strange as I am unable to locate a file name with this string / substring '(.obj' inside....

            do you have any clue to solve this problem ?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #9

            @rparon Did you do a complete rebuild after switching to that Qt version?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rparon
              wrote on last edited by
              #10

              yes, I put the sources of Qt 6.8.2 in C:/Qt/6.8.2/64 and the library was compiled with VS2022 after executing

              configure.bat -platform win32-msvc -release -static -static-runtime -prefix C:\Qt/Qt6.8.2/64 -commercial -confirm-license -plugin-manifests -nomake examples -nomake tests

              then

              cmake --build --parallel

              ninja install

              still I have previous version in C:/Qt/6.8.1/64 and C:/Qt/6.8.1/32 but I suppose there are no global vars which may cause conflicts...

              jsulmJ 1 Reply Last reply
              0
              • R rparon

                yes, I put the sources of Qt 6.8.2 in C:/Qt/6.8.2/64 and the library was compiled with VS2022 after executing

                configure.bat -platform win32-msvc -release -static -static-runtime -prefix C:\Qt/Qt6.8.2/64 -commercial -confirm-license -plugin-manifests -nomake examples -nomake tests

                then

                cmake --build --parallel

                ninja install

                still I have previous version in C:/Qt/6.8.1/64 and C:/Qt/6.8.1/32 but I suppose there are no global vars which may cause conflicts...

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #11

                @rparon I'm not talking about building Qt, I'm talking about building your project

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  rparon
                  wrote on last edited by
                  #12

                  sure, it was the first think to do...

                  1. in build directory manually delete all files and folders (CMake cache,MOC files etc.etc.)
                  2. manually delete CMakeList.txt.user to force Qt Creator to redefine all the makefiles

                  you may imagine I was quite surprised to see exactly the same error reported -> LINK : fatal error LNK1181: cannot open input file '(.obj'

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    rparon
                    wrote on last edited by
                    #13

                    a possibility, which I have not investigated, is that Qt Creator or CMake may store something outside the build directory, but I am not aware of that...

                    jsulmJ 1 Reply Last reply
                    0
                    • R rparon

                      a possibility, which I have not investigated, is that Qt Creator or CMake may store something outside the build directory, but I am not aware of that...

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @rparon Then you should check your CMakeLists.txt file or post it here, so others can take a look. Something must be wrong there.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        rparon
                        wrote on last edited by
                        #15

                        the cause was a bad format in module-definition (.def file) which, for unknown reasons, generated that error when linking ...
                        Now Qt 6.8.2 works fine, thank you for help.

                        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