Qt 5.12 Windows static сборка.



  • Добрый день. Решил попробовать собрать проект в статику под Windows.
    Использовал следующую тему https://vladsol.tk/2017/05/qt-5-8-0-static-build/
    Но не пошло. Пробовал на пакетах Qt5.12.3, Qt5.11.1,Qt5.9.5
    configure.bat отрабатывает на отлично:

    Configure summary:
    
    Build type: win32-g++ (i386, CPU features: <none>)
    Configuration: sse2 sse3 ssse3 sse4_1 sse4_2 avx avx2 avx512f avx512bw avx512cd avx512dq avx512er avx512ifma avx512pf avx512vbmi avx512vl compile_examples f16c largefile optimize_debug precompile_header debug_and_release release debug build_all c++11 c++14 concurrent dbus no-pkg-config release_tools static stl
    Build options:
      Mode ................................... debug and release; default link: debug; optimized tools
      Optimize debug build ................... yes
      Optimize release build for size ........ no
      Building shared libraries .............. no
      Using C++ standard ..................... C++14
      Using gold linker ...................... no
      Using precompiled headers .............. yes
      Using LTCG ............................. no
      Target compiler supports:
        SSE .................................. SSE2 SSE3 SSSE3 SSE4.1 SSE4.2
        AVX .................................. AVX AVX2 F16C
        AVX512 ............................... F ER CD PF DQ BW VL IFMA VBMI
      Build parts ............................ libs
      App store compliance ................... no
    Qt modules and options:
      Qt Concurrent .......................... yes
      Qt D-Bus ............................... yes
      Qt D-Bus directly linked to libdbus .... no
      Qt Gui ................................. yes
      Qt Network ............................. yes
      Qt Sql ................................. yes
      Qt Testlib ............................. yes
      Qt Widgets ............................. yes
      Qt Xml ................................. yes
    Support enabled for:
      Using pkg-config ....................... no
      QML debugging .......................... yes
      udev ................................... no
      Using system zlib ...................... no
    Qt Core:
      DoubleConversion ....................... yes
        Using system DoubleConversion ........ no
      GLib ................................... no
      iconv .................................. no
      ICU .................................... no
      Logging backends:
        journald ............................. no
        syslog ............................... no
        slog2 ................................ no
      Using system PCRE2 ..................... no
    Qt Network:
      getaddrinfo() .......................... yes
      getifaddrs() ........................... no
      IPv6 ifname ............................ no
      libproxy ............................... no
      OpenSSL ................................ no
        Qt directly linked to OpenSSL ........ no
      SCTP ................................... no
      Use system proxies ..................... yes
    Qt Gui:
      Accessibility .......................... yes
      FreeType ............................... yes
        Using system FreeType ................ no
      HarfBuzz ............................... yes
        Using system HarfBuzz ................ no
      Fontconfig ............................. no
      Image formats:
        GIF .................................. yes
        ICO .................................. yes
        JPEG ................................. yes
          Using system libjpeg ............... no
        PNG .................................. yes
          Using system libpng ................ no
      EGL .................................... no
      OpenVG ................................. no
      OpenGL:
        ANGLE ................................ no
        Desktop OpenGL ....................... yes
        Dynamic OpenGL ....................... no
        OpenGL ES 2.0 ........................ no
        OpenGL ES 3.0 ........................ no
        OpenGL ES 3.1 ........................ no
      Session Management ..................... yes
    Features used by QPA backends:
      evdev .................................. no
      libinput ............................... no
      INTEGRITY HID .......................... no
      mtdev .................................. no
      tslib .................................. no
      xkbcommon-evdev ........................ no
    QPA backends:
      DirectFB ............................... no
      EGLFS .................................. no
      LinuxFB ................................ no
      VNC .................................... no
      Mir client ............................. no
      Windows:
        Direct 2D ............................ no
        DirectWrite .......................... yes
        DirectWrite 2 ........................ no
    Qt Widgets:
      GTK+ ................................... no
      Styles ................................. Fusion Windows WindowsXP WindowsVista
    Qt PrintSupport:
      CUPS ................................... no
    Qt Sql:
      DB2 (IBM) .............................. no
      InterBase .............................. no
      MySql .................................. no
      OCI (Oracle) ........................... no
      ODBC ................................... yes
      PostgreSQL ............................. yes
      SQLite2 ................................ no
      SQLite ................................. yes
        Using system provided SQLite ......... no
      TDS (Sybase) ........................... no
    Qt SerialBus:
      Socket CAN ............................. no
      Socket CAN FD .......................... no
    QtXmlPatterns:
      XML schema support ..................... yes
    Qt QML:
      QML interpreter ........................ yes
      QML network support .................... yes
    Qt Quick:
      Direct3D 12 ............................ no
      AnimatedImage item ..................... yes
      Canvas item ............................ yes
      Support for Qt Quick Designer .......... yes
      Flipable item .......................... yes
      GridView item .......................... yes
      ListView item .......................... yes
      Path support ........................... yes
      PathView item .......................... yes
      Positioner items ....................... yes
      ShaderEffect item ...................... yes
      Sprite item ............................ yes
    Qt Gamepad:
      SDL2 ................................... no
    Qt 3D:
      Assimp ................................. yes
      System Assimp .......................... no
      Output Qt3D Job traces ................. no
      Output Qt3D GL traces .................. no
    Qt 3D GeometryLoaders:
      Autodesk FBX ........................... no
    Qt Wayland Client ........................ no
    Qt Wayland Compositor .................... no
    Qt Bluetooth:
      BlueZ .................................. no
      BlueZ Low Energy ....................... no
      Linux Crypto API ....................... no
    Qt Sensors:
      sensorfw ............................... no
    Qt Quick Controls 2:
      Styles ................................. Default Material Universal
    Qt Quick Templates 2:
      Hover support .......................... yes
      Multi-touch support .................... yes
    Qt Positioning:
      Gypsy GPS Daemon ....................... no
      WinRT Geolocation API .................. no
    Qt Location:
      Geoservice plugins:
        OpenStreetMap ........................ yes
        HERE ................................. yes
        Esri ................................. yes
        Mapbox ............................... yes
        MapboxGL ............................. yes
        Itemsoverlay ......................... yes
    Qt Multimedia:
      ALSA ................................... no
      GStreamer 1.0 .......................... no
      GStreamer 0.10 ......................... no
      Video for Linux ........................ no
      OpenAL ................................. no
      PulseAudio ............................. no
      Resource Policy (libresourceqt5) ....... no
      Windows Audio Services ................. no
      DirectShow ............................. yes
      Windows Media Foundation ............... no
      Media player backend ................... DirectShow
    
    Note: Using static linking will disable the use of dynamically
    loaded plugins. Make sure to import all needed static plugins,
    or compile needed modules into the library.
    
    Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.
    
    Qt is now configured for building. Just run 'mingw32-make'.
    Once everything is built, you must run 'mingw32-make install'.
    Qt will be installed into 'C:\Qt\Qt5.9.5-static\mingw53_32'.
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    

    При сборке проекта вываливается ошибка :

    In file included from ..\..\..\include/QtCore/qcompilerdetection.h:1:0,
                     from ..\..\..\include/QtCore/../../src/corelib/global/qglobal.h:98,
                     from ..\..\..\include/QtCore/qglobal.h:1,
                     from ..\..\..\include/QtCore/../../src/corelib/tools/qalgorithms.h:43,
                     from ..\..\..\include/QtCore/qalgorithms.h:1,
                     from ..\..\..\include/QtCore/../../src/corelib/tools/qlist.h:43,
                     from ..\..\..\include/QtCore/qlist.h:1,
                     from ..\..\..\include/QtCore/../../src/corelib/tools/qstringlist.h:41,
                     from ..\..\..\include/QtCore/qstringlist.h:1,
                     from ..\..\corelib\io\qstandardpaths.h:43,
                     from ..\..\corelib\io\qstandardpaths_win.cpp:40:
    ..\..\corelib\io\qstandardpaths_win.cpp: In function 'QString sHGetKnownFolderPath(const GUID&, QStandardPaths::StandardLocation, bool)':
    ..\..\corelib\io\qstandardpaths_win.cpp:141:80: error: 'KF_FLAG_DONT_VERIFY' was not declared in this scope
         if (Q_LIKELY(sHGetKnownFolderPath && SUCCEEDED(sHGetKnownFolderPath(clsid, KF_FLAG_DONT_VERIFY, 0, &path)))) {
                                                                                    ^
    ..\..\..\include/QtCore/../../src/corelib/global/qcompilerdetection.h:240:49: note: in definition of macro 'Q_LIKELY'
     #  define Q_LIKELY(expr)    __builtin_expect(!!(expr), true)
                                                     ^
    Makefile.Release:11243: recipe for target '.obj/release/qstandardpaths_win.o' failed
    mingw32-make[4]: *** [.obj/release/qstandardpaths_win.o] Error 1
    gcc -c -fno-keep-inline-dllexport -ffunction-sections -O2 -fno-exceptions -Wall -W -Wextra -DUNICODE -D_UNICODE -DWIN32 -DUNICODE -DQT_STATIC_BUILD -DQT_VERSION_STR="\"5.9.5\"" -DQT_VERSION_MAJOR=5 -DQT_VERSION_MINOR=9 -DQT_VERSION_PATCH=5 -DQT_BOOTSTRAPPED -DQT_NO_CAST_TO_ASCII -DQT_NO_FOREACH -DQT_NO_CAST_FROM_ASCII -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_BOOTSTRAP_LIB -DQT_BUILDING_QT -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -I. -I..\..\3rdparty\zlib\src -I..\..\..\include -I..\..\..\include\QtCore -I..\..\..\include\QtCore\5.9.5 -I..\..\..\include\QtCore\5.9.5\QtCore -I..\..\..\include\QtXml -I..\..\..\include\QtXml\5.9.5 -I..\..\..\include\QtXml\5.9.5\QtXml -Itmp -IC:\psql9.6\include -I..\..\..\mkspecs\win32-g++  -o .obj\release\adler32.o ..\..\3rdparty\zlib\src\adler32.c
    
    
    

    Куда копать не ясно. Все пробовал на виртуалках с Windows10 LTSB и Windows7 PRO
    Подскажите кто знает?



  • Искать откуда этот KF_FLAG_DONT_VERIFY берется



  • Для себя делал статические сборки Qt в том числе и версии 5.12 с помощью скрипта, могу поделиться, вот только при поытке прикрепить файл пишет что у меня недостаточно прав.[0_1565472078569_windows-build-qt12-static.ps1](Загрузка 100%)



  • Буду признателен за помощь dsobodchikov@gmail.com.
    Я уже попробовал различные варианты. Нашел тоже скрипт, сравню с Вашим, но все равно не идет. Даже попробовал собрать с оригинальным MinGW, на машинах с Win10 не пошло. Еще проверю на Win7, но только в понедельник.
    А можете закачать свою статику на облако, если на жалко, я бы ее от туда прихватил .
    Спасибо.



  • @honey12345 said in Qt 5.12 Windows static сборка.:

    dsobodchikov@gmail.com

    Выслал скрипт на почту. Этим скриптом я делал статическую сборку Qt5.12 на Win 10, все работает как надо, какие либо дополнительные проги не ставил. Только в самом скрипте надо будет заменить путь к исходному коду и путь для установки. И еще один момент: по умолчанию Power shell блокирует запуск скриптов, надо в натсройках системы разрешение ставить



  • Прилетела ошибка отправки письма.



  • Содержимое скрипта

    #-----------------------------------------------------------------------------
    # 
    #  Copyright (c) 2013, Thierry Lelegard
    #  All rights reserved.
    # 
    #  Redistribution and use in source and binary forms, with or without
    #  modification, are permitted provided that the following conditions are met:
    # 
    #  1. Redistributions of source code must retain the above copyright notice,
    #     this list of conditions and the following disclaimer. 
    #  2. Redistributions in binary form must reproduce the above copyright
    #     notice, this list of conditions and the following disclaimer in the
    #     documentation and/or other materials provided with the distribution. 
    # 
    #  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    #  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    #  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    #  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    #  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    #  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    #  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    #  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    #  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    #  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    #  THE POSSIBILITY OF SUCH DAMAGE.
    # 
    #-----------------------------------------------------------------------------
    
    <#
     .SYNOPSIS
    
      Build a static version of Qt for Windows.
    
     .DESCRIPTION
    
      This scripts downloads Qt source code, compiles and installs a static version
      of Qt. It assumes that a prebuilt Qt / MinGW environment is already installed,
      typically in C:\Qt. This prebuilt environment uses shared libraries. It is
      supposed to remain the main development environment for Qt. This script adds
      a static version of the Qt libraries in order to allow the construction of
      standalone and self-sufficient executable.
    
      This script is typically run from the Windows Explorer.
    
      Requirements:
      - Windows PowerShell 3.0 or higher.
      - 7-zip.
    
     .PARAMETER QtSrcUrl
    
      URL of the Qt source file archive.
      By default, use the latest identified version.
    
     .PARAMETER QtStaticDir
    
      Root directory where the static versions of Qt are installed.
      By default, use C:\Qt\Static.
    
     .PARAMETER QtVersion
    
      The Qt version. By default, this script tries to extract the version number
      from the Qt source file name.
    
     .PARAMETER MingwDir
    
      Root directory of the MinGW prebuilt environment. By default, use the version
      which was installed by the prebuilt Qt environment.
    
     .PARAMETER NoPause
    
      Do not wait for the user to press <enter> at end of execution. By default,
      execute a "pause" instruction at the end of execution, which is useful
      when the script was run from Windows Explorer.
    #>
    
    [CmdletBinding()]
    param(
        $QtSrcUrl = "http://download.qt-project.org/official_releases/qt/5.3/5.3.1/single/qt-everywhere-opensource-src-5.3.1.7z",
        $QtStaticDir = "E:\Qt\Static",
        $QtVersion = "Qt5.12.0-Static",
        $MingwDir = "e:\Qt\Qt5.12.0\Tools\mingw730_64\",
        [switch]$NoPause = $false
    )
    
    # PowerShell execution policy.
    Set-StrictMode -Version 3
    
    #-----------------------------------------------------------------------------
    # Main code
    #-----------------------------------------------------------------------------
    
    function Main
    {
        # Check that 7zip is installed. We use it to expand the downloaded archive.
        [void] (Get-7zip)
    
        # Get Qt source file name from URL.
        # $QtSrcFileName = Split-Path -Leaf $QtSrcUrl
    
        # If Qt version is not specified on the command line, try to extract the value.
        if (-not $QtVersion) {
            $QtVersion = $QtSrcFileName -replace "`.[^`.]*$",''
            $QtVersion = $QtVersion -replace 'qt-',''
            $QtVersion = $QtVersion -replace 'everywhere-',''
            $QtVersion = $QtVersion -replace 'opensource-',''
            $QtVersion = $QtVersion -replace 'src-',''
            $QtVersion = $QtVersion -replace '-src',''
        }
        Write-Output "Building static Qt version $QtVersion"
    
        # Qt installation directory.
        $QtDir = "$QtStaticDir\$QtVersion"
    
        # Get MinGW root directory, if not specified on the command line.
        if (-not $MingwDir) {
            # Search all instances of gcc.exe from C:\Qt prebuilt environment.
            $GccList = @(Get-ChildItem -Path E:\Qt\*\Tools\mingw*\bin\gcc.exe | ForEach-Object FullName | Sort-Object)
            if ($GccList.Length -eq 0) {
                Exit-Script "MinGW environment not found, no Qt prebuilt version?"
            }
            $MingwDir = (Split-Path -Parent (Split-Path -Parent $GccList[$GccList.Length - 1]))
        }
        Write-Output "Using MinGW from $MingwDir"
    
        # Build the directory tree where the static version of Qt will be installed.
        Create-Directory $QtStaticDir\src
        Create-Directory $QtDir
    
        # Download the Qt source package if not yet done.
        #Download-File $QtSrcUrl $QtStaticDir\src\$QtSrcFileName
    
        # Directory of expanded packages.
        $QtSrcDir = "e:\Qt\qt-everywhere-src-5.12.0\"
    
        # Expand archives if not yet done
        # Expand-Archive $QtStaticDir\src\$QtSrcFileName $QtStaticDir\src $QtSrcDir
    
        # Patch Qt's mkspecs for static build.
        $File = "$QtSrcDir\qtbase\mkspecs\win32-g++\qmake.conf"
        if (-not (Select-String -Quiet -SimpleMatch -CaseSensitive "# [QT-STATIC-PATCH]" $File)) {
            Write-Output "Patching $File ..."
            Copy-Item $File "$File.orig"
            @"
    
    # [QT-STATIC-PATCH]
    QMAKE_LFLAGS += -static -static-libgcc
    QMAKE_CFLAGS_RELEASE -= -O2
    QMAKE_CFLAGS_RELEASE += -Os -momit-leaf-frame-pointer
    DEFINES += QT_STATIC_BUILD
    "@ | Out-File -Append $File -Encoding Ascii
        }
    
        # Set a clean path including MinGW.
        $env:Path = "$MingwDir\bin;$MingwDir\opt\bin;$env:SystemRoot\system32;$env:SystemRoot"
    
        # Force English locale to avoid weird effects of tools localization.
        $env:LANG = "en"
    
        # Set environment variable QT_INSTALL_PREFIX. Documentation says it should be
        # used by configure as prefix but this does not seem to work. So, we will
        # also specify -prefix option in configure.
        $env:QT_INSTALL_PREFIX = $QtDir
    
        # Configure, compile and install Qt.
        Push-Location $QtSrcDir
        cmd /c "configure.bat -static -debug-and-release -platform win32-g++ -prefix $QtDir `
            -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -sql-sqlite -no-openssl `
            -opensource -confirm-license `
            -make libs -nomake tools -nomake examples -nomake tests"
        mingw32-make -k -j7
        mingw32-make -k install
        Pop-Location
    
        # Patch Qt's installed mkspecs for static build of application.
        $File = "$QtSrcDir\qtbase\mkspecs\win32-g++\qmake.conf"
        @"
    CONFIG += static
    "@ | Out-File -Append $File -Encoding Ascii
    
        Exit-Script
    }
    
    #-----------------------------------------------------------------------------
    # A function to exit this script. The Message parameter is used on error.
    #-----------------------------------------------------------------------------
    
    function Exit-Script ([string]$Message = "")
    {
        $Code = 0
        if ($Message -ne "") {
            Write-Output "ERROR: $Message"
            $Code = 1
        }
        if (-not $NoPause) {
            pause
        }
        exit $Code
    }
    
    #-----------------------------------------------------------------------------
    # Silently create a directory.
    #-----------------------------------------------------------------------------
    
    function Create-Directory ([string]$Directory)
    {
        [void] (New-Item -Path $Directory -ItemType "directory" -Force)
    }
    
    #-----------------------------------------------------------------------------
    # Download a file if not yet present.
    # Warning: If file is present but incomplete, do not download it again.
    #-----------------------------------------------------------------------------
    
    function Download-File ([string]$Url, [string]$OutputFile)
    {
        $FileName = Split-Path $Url -Leaf
        if (-not (Test-Path $OutputFile)) {
            # Local file not present, start download.
            Write-Output "Downloading $Url ..."
            try {
                $webclient = New-Object System.Net.WebClient
                $webclient.DownloadFile($Url, $OutputFile)
            }
            catch {
                # Display exception.
                $_
                # Delete partial file, if any.
                if (Test-Path $OutputFile) {
                    Remove-Item -Force $OutputFile
                }
                # Abort
                Exit-Script "Error downloading $FileName"
            }
            # Check that the file is present.
            if (-not (Test-Path $OutputFile)) {
                Exit-Script "Error downloading $FileName"
            }
        }
    }
    
    #-----------------------------------------------------------------------------
    # Get path name of 7zip, abort if not found.
    #-----------------------------------------------------------------------------
    
    function Get-7zip
    {
        $Exe = "C:\Program Files\7-Zip\7z.exe"
        if (-not (Test-Path $Exe)) {
            $Exe = "C:\Program Files (x86)\7-Zip\7z.exe"
        }
        if (-not (Test-Path $Exe)) {
            Exit-Script "7-zip not found, install it first, see http://www.7-zip.org/"
        }
        $Exe
    }
    
    #-----------------------------------------------------------------------------
    # Expand an archive file if not yet done.
    #-----------------------------------------------------------------------------
    
    function Expand-Archive ([string]$ZipFile, [string]$OutDir, [string]$CheckFile)
    {
        # Check presence of expected expanded file or directory.
        if (-not (Test-Path $CheckFile)) {
            Write-Output "Expanding $ZipFile ..."
            & (Get-7zip) x $ZipFile "-o$OutDir" | Select-String -Pattern "^Extracting " -CaseSensitive -NotMatch
            if (-not (Test-Path $CheckFile)) {
                Exit-Script "Error expanding $ZipFile, $OutDir\$CheckFile not found"
            }
        }
    }
    
    #-----------------------------------------------------------------------------
    # Execute main code.
    #-----------------------------------------------------------------------------
    
    . Main
    


  • @homer2000 said in Qt 5.12 Windows static сборка.:

    Содержимое скрипта
    Спасибо, это я протормозил, одну букву пропустил в почте : dslobodchikov@gmail.com.



  • Добрый день. Потренировавшись пару дней выяснил следующее :
    Qt собирается в статику нормально, без опции -sql-psql -I C:\psql9.6\include -L C:\psql9.6\lib. Как только добавляю эту опцию в строку конфигурации, настройка конфигурации проходит без ошибок. А вот дальше на этапе компиляции, при попытке подключить хэдеры постгреса, валятся ошибки. Ничего не смог нарыть как собрать нормально ( при этом на линуксе все нормально собралось). Качал исходники с сайте постгреса - бесполезно.
    Собрал Qt без опции -sql-psql, но в этом случае не могу подключится к postgres.
    Вот и не ясно что делать ? Может кто еще что подскажет.



  • Мб версии постгреса разные на windows и linux. А сборка без static нормально проходит?


 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.