使用MinGW与-openssl链接的静态编译Qt 5.13.1(Windows 10)

时间:2019-10-20 19:25:56

标签: c++ qt ssl openssl qmake

回复:Static compilation. Qt 5.12.3

美好的一天

Qt论坛建议我创建一个新帖子,因为链接的帖子“很旧”

这本质上是对某些“错误”的确认,我不确定确切的问题是什么,但是我可以简单地向您提供我的编译脚本和错误。

目的是针对Qt编译OpenSSL,这将允许我编译我可以交付的单个多合一二进制应用程序。我能够达到this but had inconsistency issues,从而使我回到了重新编译的方面。

重复的错误编译行如下所示:

..\..\..\..\include\QtWindowsUIAutomationSupport\5.13.1/QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h:1:10: fatal error: ../../../../../src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h: No such file or directory
 #include "../../../../../src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

问题:

如何使用-openssl-linked配置标志通过OpenSSL静态编译Qt?


下面的其他详细信息: 我的设置环境:

  • 使用MinGW32进行编译
    • 使用OpenSSL 1.1.1d预编译的版本,可从here下载,它具有我链接到的MinGW库,在文章的后面进一步显示。
  • PATH已添加版本/bin的OpenSSL OpenSSL 1.1.1d 10 Sep 2019

我用来编译Qt的脚本可以在here页面上的this中找到。为了添加OpenSSL,我使用this作为指导。

我的编译脚本配置为:

    $QtSrcUrl = "F:\Qt\Static-OpenSSL-Linked\src\qt-everywhere-src-5.13.1.tar",
    $QtStaticDir = "F:\Qt\Static-OpenSSL-Linked",
    $QtVersion = "",
    $arch = "32",
    $MingwDir = "",
    $threads = "16",
    $OPENSSL_HOME = "C:\OpenSSL\OpenSSL-Win$($arch)",

    set OPENSSL_LIBS="-lssl -lcrypto"
    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 -openssl-linked -I $($OPENSSL_HOME)\include -L$($OPENSSL_HOME)\lib\MinGW `
        -opensource -confirm-license `
        -make libs -nomake tools -nomake examples -nomake tests"
    cmd /c "mingw32-make -k -j$($threads)"

我已经在

安装了OpenSSL。
PS C:\OpenSSL\OpenSSL-Win32> ls

Directory: C:\OpenSSL\OpenSSL-Win32

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2019/09/30     07:27                bin
d-----       2019/09/30     07:27                exp
d-----       2019/09/30     07:27                include
d-----       2019/09/30     07:27                lib
d-----       2019/09/30     07:27                tests
-a----       2019/09/11     18:10             89 acknowledgements.txt
-a----       2019/09/11     18:10            752 authors.txt
-a----       2019/09/11     18:10         596279 changes.txt
-a----       2019/09/11     18:10           6408 c_rehash.pl
-a----       2019/09/11     18:10             86 faq.txt
-a----       2019/09/11     18:10        2515456 libcrypto-1_1.dll
-a----       2019/09/11     18:10         530432 libssl-1_1.dll
-a----       2019/09/11     18:10           6246 license.txt
-a----       2019/09/11     18:10          43136 news.txt
-a----       2019/09/11     18:10           3251 readme.txt
-a----       2019/09/30     07:27          96904 unins000.dat
-a----       2019/09/30     07:26         730789 unins000.exe

我看到一些帖子引用了%OPENSSL_HOME%%OPENSSL_HOME%\libs并使用了设置为

的env变量
OPENSSL_LIBS="-lssl -lcrypto"
我尝试过的

,但总是抱怨找不到“ -lssl”。因此,我选择了以下目录,它似乎可以正常工作并选择了-lssl -lcrypto(不确定这是否可能是编译问题的帮凶)。

PS C:\OpenSSL\OpenSSL-Win32\lib\MinGW> ls

    Directory: C:\OpenSSL\OpenSSL-Win32\lib\MinGW

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       2019/09/11     18:11        3347286 libcrypto.a
-a----       2019/09/11     18:10         109020 libcrypto.def
-a----       2019/09/11     18:11         385126 libssl.a
-a----       2019/09/11     18:10          14033 libssl.def

配置摘要:(重要部分)

Qt Network:
  getifaddrs() ........................... no
  IPv6 ifname ............................ no
  libproxy ............................... no
  Schannel ............................... no
  OpenSSL ................................ yes
    Qt directly linked to OpenSSL ........ yes
  OpenSSL 1.1 ............................ yes
  DTLS ................................... yes
  OCSP-stapling .......................... yes
  SCTP ................................... no
  Use system proxies ..................... yes

错误行的更多示例如下:

In file included from uiautomation\qwindowsuiabaseprovider.h:50:0,
                 from uiautomation\qwindowsuiabaseprovider.cpp:43:
..\..\..\..\include\QtWindowsUIAutomationSupport\5.13.1/QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h:1:10: fatal error: ../../../../../src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h: No such file or directory
 #include "../../../../../src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
mingw32-make[6]: *** [Makefile.Debug:11357: .obj/debug/qwindowsuiabaseprovider.o] Error 1
g++ -c -fno-keep-inline-dllexport -g -Og -std=c++1z -fno-exceptions -Wall -W -Wextra -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -ffunction-sections -fdata-sections -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_STATIC_BUILD -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DQT_NO_CAST_FROM_ASCII -DQT_NO_FOREACH -DLIBEGL_NAME=libEGL -DLIBGLESV2_NAME=libGLESv2 -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_EXCEPTIONS -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_EVENTDISPATCHER_SUPPORT_LIB -DQT_FONTDATABASE_SUPPORT_LIB -DQT_THEME_SUPPORT_LIB -DQT_ACCESSIBILITY_SUPPORT_LIB -DQT_WINDOWSUIAUTOMATION_SUPPORT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_PLUGIN_RESOURCE_INIT_FUNCTION=qwindowsd_plugin_resource_init -I. -I. -I..\..\..\3rdparty\wintab -I..\..\..\..\include -I..\..\..\..\include\QtEventDispatcherSupport -I..\..\..\..\include\QtEventDispatcherSupport\5.13.1 -I..\..\..\..\include\QtEventDispatcherSupport\5.13.1\QtEventDispatcherSupport -I..\..\..\..\include\QtFontDatabaseSupport -I..\..\..\..\include\QtFontDatabaseSupport\5.13.1 -I..\..\..\..\include\QtFontDatabaseSupport\5.13.1\QtFontDatabaseSupport -I..\..\..\..\include\QtThemeSupport -I..\..\..\..\include\QtThemeSupport\5.13.1 -I..\..\..\..\include\QtThemeSupport\5.13.1\QtThemeSupport -I..\..\..\..\include\QtAccessibilitySupport -I..\..\..\..\include\QtAccessibilitySupport\5.13.1 -I..\..\..\..\include\QtAccessibilitySupport\5.13.1\QtAccessibilitySupport -I..\..\..\..\include\QtWindowsUIAutomationSupport -I..\..\..\..\include\QtWindowsUIAutomationSupport\5.13.1 -I..\..\..\..\include\QtWindowsUIAutomationSupport\5.13.1\QtWindowsUIAutomationSupport -I..\..\..\..\include\QtGui\5.13.1 -I..\..\..\..\include\QtGui\5.13.1\QtGui -I..\..\..\..\include\QtGui -I..\..\..\..\include\QtCore\5.13.1 -I..\..\..\..\include\QtCore\5.13.1\QtCore -I..\..\..\..\include\QtCore -I.moc\debug -IC:\OpenSSL\OpenSSL-Win32\include -I..\..\..\..\mkspecs\win32-g++  -o .obj\debug\qwindowsuiavalueprovider.o uiautomation\qwindowsuiavalueprovider.cpp

和另一个例子

In file included from ..\windows\uiautomation\qwindowsuiabaseprovider.h:50:0,
                 from ..\windows\uiautomation\qwindowsuiagriditemprovider.h:46,
                 from ..\windows\uiautomation\qwindowsuiagriditemprovider.cpp:43:
..\..\..\..\include\QtWindowsUIAutomationSupport\5.13.1/QtWindowsUIAutomationSupport/private/qwindowsuiawrapper_p.h:1:10: fatal error: ../../../../../src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h: No such file or directory
 #include "../../../../../src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
mingw32-make[6]: *** [Makefile.Debug:14323: .obj/debug/qwindowsuiagriditemprovider.o] Error 1
g++ -c -fno-keep-inline-dllexport -g -Og -std=c++1z -fno-exceptions -Wall -W -Wextra -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -ffunction-sections -fdata-sections -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_STATIC_BUILD -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DQT_NO_CAST_FROM_ASCII -DQT_NO_FOREACH -DLIBEGL_NAME=libEGL -DLIBGLESV2_NAME=libGLESv2 -DQT_DEPRECATED_WARNINGS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_EXCEPTIONS -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_EVENTDISPATCHER_SUPPORT_LIB -DQT_FONTDATABASE_SUPPORT_LIB -DQT_THEME_SUPPORT_LIB -DQT_ACCESSIBILITY_SUPPORT_LIB -DQT_WINDOWSUIAUTOMATION_SUPPORT_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_PLUGIN_RESOURCE_INIT_FUNCTION=qdirect2dd_plugin_resource_init -I. -I..\windows -I..\..\..\3rdparty\wintab -I..\..\..\..\include -I..\..\..\..\include\QtEventDispatcherSupport -I..\..\..\..\include\QtEventDispatcherSupport\5.13.1 -I..\..\..\..\include\QtEventDispatcherSupport\5.13.1\QtEventDispatcherSupport -I..\..\..\..\include\QtFontDatabaseSupport -I..\..\..\..\include\QtFontDatabaseSupport\5.13.1 -I..\..\..\..\include\QtFontDatabaseSupport\5.13.1\QtFontDatabaseSupport -I..\..\..\..\include\QtThemeSupport -I..\..\..\..\include\QtThemeSupport\5.13.1 -I..\..\..\..\include\QtThemeSupport\5.13.1\QtThemeSupport -I..\..\..\..\include\QtAccessibilitySupport -I..\..\..\..\include\QtAccessibilitySupport\5.13.1 -I..\..\..\..\include\QtAccessibilitySupport\5.13.1\QtAccessibilitySupport -I..\..\..\..\include\QtWindowsUIAutomationSupport -I..\..\..\..\include\QtWindowsUIAutomationSupport\5.13.1 -I..\..\..\..\include\QtWindowsUIAutomationSupport\5.13.1\QtWindowsUIAutomationSupport -I..\..\..\..\include\QtGui\5.13.1 -I..\..\..\..\include\QtGui\5.13.1\QtGui -I..\..\..\..\include\QtGui -I..\..\..\..\include\QtCore\5.13.1 -I..\..\..\..\include\QtCore\5.13.1\QtCore -I..\..\..\..\include\QtCore -I.moc\debug -IC:\OpenSSL\OpenSSL-Win32\include -I..\..\..\..\mkspecs\win32-g++  -o .obj\debug\qwindowsuiawindowprovider.o ..\windows\uiautomation\qwindowsuiawindowprovider.cpp

编译完成前的最后几行,我有这个:

F:\Qt\Static-OpenSSL-Linked\src\qt-everywhere-src-5.13.1\qtbase\bin\qmake.exe -install qinstall F:\Qt\Static-OpenSSL-Linked\src\qt-everywhere-src-5.13.1\qtbase\mkspecs\winrt-x86-msvc2017 F:\Qt\Static-OpenSSL-Linked\5.13.1_x32\mkspecs\winrt-x86-msvc2017
F:\Qt\Static-OpenSSL-Linked\src\qt-everywhere-src-5.13.1\qtbase\bin\qmake.exe -install qinstall F:\Qt\Static-OpenSSL-Linked\src\qt-everywhere-src-5.13.1\qtbase\mkspecs\winrt-x86-msvc2019 F:\Qt\Static-OpenSSL-Linked\5.13.1_x32\mkspecs\winrt-x86-msvc2019
mingw32-make[1]: Target 'install' not remade because of errors.
mingw32-make[1]: Leaving directory 'F:/Qt/Static-OpenSSL-Linked/src/qt-everywhere-src-5.13.1/qtbase'
mingw32-make: *** [Makefile:94: module-qtbase-install_subtargets] Error 2
mingw32-make: Target 'install' not remade because of errors.

配置摘要:

Build type: win32-g++ (i386, CPU features: <none>)
Compiler: gcc 7.3.0
Configuration: sse2 aesni 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 rdrnd shani x86SimdAlways debug_and_release release debug build_all c++11 c++14 c++1z 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 ....................... C11
  Using C++ standard ..................... C++17
  Generating GDB index ................... no
  Using precompiled headers .............. yes
  Using LTCG ............................. no
  Target compiler supports:
    SSE .................................. SSE2 SSE3 SSSE3 SSE4.1 SSE4.2
    AVX .................................. AVX AVX2
    AVX512 ............................... F ER CD PF DQ BW VL IFMA VBMI
    Other x86 ............................ AES F16C RDRAND SHA
    Intrinsics without -mXXX option ...... yes
  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
  udev ................................... no
  Using system zlib ...................... no
  Zstandard support ...................... no
Qt Core:
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ no
  GLib ................................... no
  iconv .................................. no
  ICU .................................... no
  Built-in copy of the MIME database ..... yes
  Tracing backend ........................ <none>
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  Using system PCRE2 ..................... no
Qt Network:
  getifaddrs() ........................... no
  IPv6 ifname ............................ no
  libproxy ............................... no
  Schannel ............................... no
  OpenSSL ................................ yes
    Qt directly linked to OpenSSL ........ yes
  OpenSSL 1.1 ............................ yes
  DTLS ................................... yes
  OCSP-stapling .......................... yes
  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
    OpenGL ES 3.2 ........................ no
  Vulkan ................................. no
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. no
  libinput ............................... no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon .............................. no
  X11 specific:
    XLib ................................. no
    XCB Xlib ............................. no
    EGL on X11 ........................... no
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. no
  LinuxFB ................................ no
  VNC .................................... no
  Mir client ............................. no
  Windows:
    Direct 2D ............................ yes
    DirectWrite .......................... yes
    DirectWrite 2 ........................ yes
Qt Sql:
  SQL item models ........................ yes
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows WindowsVista
Qt PrintSupport:
  CUPS ................................... no
Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... yes
  PostgreSQL ............................. no
  SQLite2 ................................ no
  SQLite ................................. yes
    Using system provided SQLite ......... no
  TDS (Sybase) ........................... no
Qt Testlib:
  Tester for item models ................. yes
Qt SerialBus:
  Socket CAN ............................. no
  Socket CAN FD .......................... no
  SerialPort Support ..................... yes
Further Image Formats:
  JasPer ................................. no
  MNG .................................... no
  TIFF ................................... yes
    Using system libtiff ................. no
  WEBP ................................... yes
    Using system libwebp ................. no
Qt QML:
  QML network support .................... yes
  QML debugging and profiling support .... yes
  QML tracing JIT support ................ no
  QML sequence object .................... yes
  QML list model ......................... yes
  QML XML http request ................... yes
  QML Locale ............................. yes
  QML delegate model ..................... 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
  TableView item ......................... yes
  Path support ........................... yes
  PathView item .......................... yes
  Positioner items ....................... yes
  Repeater item .......................... yes
  ShaderEffect item ...................... yes
  Sprite item ............................ yes
Qt Scxml:
  ECMAScript data model for QtScxml ...... yes
Qt Gamepad:
  SDL2 ................................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Output Qt3D Job traces ................. no
  Output Qt3D GL traces .................. no
  Use SSE2 instructions .................. no
  Use AVX2 instructions .................. no
  Aspects:
    Render aspect ........................ yes
    Input aspect ......................... yes
    Logic aspect ......................... yes
    Animation aspect ..................... yes
    Extras aspect ........................ yes
Qt 3D Renderers:
  OpenGL Renderer ........................ yes
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
  WinRT Bluetooth API (desktop & UWP) .... no
  WinRT advanced bluetooth low energy API (desktop & UWP) . no
Qt Sensors:
  sensorfw ............................... no
Qt Quick Controls 2:
  Styles ................................. Default Fusion Imagine 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:
  Qt.labs.location experimental QML plugin . yes
  Geoservice plugins:
    OpenStreetMap ........................ yes
    HERE ................................. yes
    Esri ................................. yes
    Mapbox ............................... yes
    MapboxGL ............................. yes
    Itemsoverlay ......................... yes
QtXmlPatterns:
  XML schema support ..................... 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
Qt Tools:
  QDoc ................................... no
Qt WebEngineCore:
  Qt WebEngine Widgets ................... yes
  Qt WebEngine Qml ....................... yes
  Embedded build ......................... no
  Full debug information ................. no
  Pepper Plugins ......................... yes
  Printing and PDF ....................... yes
  Proprietary Codecs ..................... no
  Spellchecker ........................... yes
  Native Spellchecker .................... no
  WebRTC ................................. yes
  Use System Ninja ....................... no
  Geolocation ............................ yes
  WebChannel support ..................... yes
  Use v8 snapshot ........................ yes
  Kerberos Authentication ................ yes
  Extensions ............................. yes
Qt WebEngineQml:
  UI Delegates ........................... yes
  Test Support ........................... no

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: When linking against OpenSSL, you can override the default
library names through OPENSSL_LIBS.
For example:
    OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked

Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.

WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.

0 个答案:

没有答案