Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

OpenSource build of Qt5.15 with OpenSSL 1.1.1g statically linked - precondition libs.openssl failed



  • I am returning to a code base that had been developed 6-7 years ago and am tasked with moving it to "current" tools and versions (joy!).

    The original code used a build of Qt 5.4 with OpenSSL 1.0.2d statically linked.

    I downloaded the source for OpenSSL 1.1.1g and built the win32 release target.

    Then I downloaded the zip file of the Qt5.15 files from https://download.qt.io/archive/qt/5.15/5.15.0/single and unzipped it to do the build. I am using a Windows 10 machine with Visual Studio 2019.

    Based on the old "config" arguments that we used when building Qt 5.4, I am trying to use similar arguments for the Qt 5.15 build:

    configure -prefix c:\Qt5_15_Build -opensource -confirm-license -nomake tests -nomake examples -platform win32-msvc -opengl desktop -debug-and-release -openssl-linked OPENSSL_LIBS="-llibcrypto -llibssl" -I C:\SSLBuild\Lib\x32\Release\include -L C:\SSLBuild\Lib\x32\Release\lib

    When I try to run this, I get the following error: ERROR:: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl' failed.

    Google searches have led me to various attempts to tweak the format in which the OpenSSL header file and library paths are specified, but I always get the same results. (I also learned to delete the config.cache file!!!)

    The contents of the config.log have not been useful to me in attempting to determine the issue.

    Any help/guidance would be appreciated. Seems like this "should" be do-able.

    Thanks,

    Bob



  • Quoted from qtbase\src\network\ssl\ssl.pri

       # Add optional SSL libs
       # Static linking of OpenSSL with msvc:
       #   - Binaries http://slproweb.com/products/Win32OpenSSL.html
       #   - also needs -lWs2_32 -lGdi32 -lAdvapi32 -lCrypt32 -lUser32
       #   - libs in <OPENSSL_DIR>\lib\VC\static
       #   - configure: -openssl-linked -openssl-linked OPENSSL_INCDIR="%OPENSSL_DIR%\include" OPENSSL_LIBDIR="%OPENSSL_DIR%\lib\VC\static" OPENSSL_LIBS="-lWs2_32 -lGdi32 -lAdvapi32 -lCrypt32 -lUser32"  OPENSSL_LIBS_DEBUG="-llibssl64MDd -llibcrypto64MDd" OPENSSL_LIBS_RELEASE="-llibssl64MD -llibcrypto64MD"

  • Lifetime Qt Champion

    Hi and welcome to devnet,
    @Robert_C said in OpenSource build of Qt5.15 with OpenSSL 1.1.1g statically linked - precondition libs.openssl failed:

    OPENSSL_LIBS="-llibcrypto -llibssl"

    Shouldn't that be "-lssl -lcrypto" ?



  • The libs created when building OpenSSL 1.1.1g were libcrypto.lib and libssl.lib. This is not a universe I normally play in. Perhaps the library names changed recently? They DEFINITELY changed completely from the days of 1.0.2d!

    ;-)

    Bob


  • Lifetime Qt Champion

    When passing a library to the linker you drop the lib prefix.



  • Will give it a try later today and post my results. I have never seen the name of a library being used by Visual Studio modified. Thanks for the suggestion and I'll be back with the results.



  • No change. Used the following arguments and got the same result:

    configure -prefix c:\Qt5_15_Build -opensource -confirm-license -nomake tests -nomake examples -platform win32-msvc -opengl desktop -debug-and-release -openssl-linked OPENSSL_LIBS="-lssl -lcrypto" -I C:\SSLBuild\Lib\x32\Release\include -L C:\SSLBuild\Lib\x32\Release\lib

    Is there a way to upload my config.log?

    There must be folks that do this using Windows 10 and Visual Studio 2019:

    1. Download OpenSSL 1.1.1g and build the Win32 release target

    2. Download Qt5.15 source and build statically linked to the OpenSSL libraries.

    Thank you very much for your ongoing assistance attempts.

    Bob



  • Rolled my sleeves up on that last attempt and worked on analyzing the config.log. It looks like the entries relevant to the "failure" are the following:

    test config.qtbase_corelib.tests.atomicfptr succeeded <--- Last line in file from "previous" test
    looking for library openssl
    Trying source 0 (type openssl) of library openssl ...
    $OPENSSL_LIBS is not set.
    => source produced no result.

    Bob



  • From Qt bug reports like:

    https://bugreports.qt.io/browse/QTBUG-65501
    https://bugreports.qt.io/browse/QTBUG-62733

    It looks like using the full OpenSSL library names, including the "lib" prefix is normal.

    Bob



  • Found examples on the internet that seem to show the lib path and the libs being both specified in the OPENSSL_LIBS value. So, I tried both of the following 'configure' argument sets, one with the "lib" prefix and one without.

    There was no change in behavior.

    configure -prefix c:\Qt5_15_Build -opensource -confirm-license -nomake tests -nomake examples -platform win32-msvc -opengl desktop -debug-and-release OPENSSL_LIBS="-LC:\SSLBuild\Lib\x32\Release\lib -lssl -lcrypto" -openssl-linked -I C:\SSLBuild\Lib\x32\Release\include

    configure -prefix c:\Qt5_15_Build -opensource -confirm-license -nomake tests -nomake examples -platform win32-msvc -opengl desktop -debug-and-release OPENSSL_LIBS="-LC:\SSLBuild\Lib\x32\Release\lib -llibssl -llibcrypto" -openssl-linked -I C:\SSLBuild\Lib\x32\Release\include

    Bob



  • Quoted from qtbase\src\network\ssl\ssl.pri

       # Add optional SSL libs
       # Static linking of OpenSSL with msvc:
       #   - Binaries http://slproweb.com/products/Win32OpenSSL.html
       #   - also needs -lWs2_32 -lGdi32 -lAdvapi32 -lCrypt32 -lUser32
       #   - libs in <OPENSSL_DIR>\lib\VC\static
       #   - configure: -openssl-linked -openssl-linked OPENSSL_INCDIR="%OPENSSL_DIR%\include" OPENSSL_LIBDIR="%OPENSSL_DIR%\lib\VC\static" OPENSSL_LIBS="-lWs2_32 -lGdi32 -lAdvapi32 -lCrypt32 -lUser32"  OPENSSL_LIBS_DEBUG="-llibssl64MDd -llibcrypto64MDd" OPENSSL_LIBS_RELEASE="-llibssl64MD -llibcrypto64MD"


  • Thank you Bonnie! That information was invaluable. Based on what you shared, I used the following configure command:

    configure -prefix c:\Qt5_15_Build -opensource -confirm-license -nomake tests -nomake examples -platform win32-msvc -opengl desktop -debug-and-release -openssl-linked OPENSSL_INCDIR="C:\SSLBuild\Lib\x32\Release\include" OPENSSL_LIBDIR="C:\SSLBuild\Lib\x32\Release\lib" OPENSSL_LIBS="-lWs2_32 -lGdi32 -lAdvapi32 -lCrypt32 -lUser32" OPENSSL_LIBS_DEBUG="-llibssl -llibcrypto" OPENSSL_LIBS_RELEASE="-llibssl -llibcrypto"

    This completed and I'm now ready to fire up nmake. (I may go back and build the debug OpenSSL libs, but for now I'm linking the release SSL libs into both the Qt Debug and Release builds.)

    The nmake ought to take 2-3 minutes, right?

    ;-)

    Bob


  • Lifetime Qt Champion

    @Robert_C said in OpenSource build of Qt5.15 with OpenSSL 1.1.1g statically linked - precondition libs.openssl failed:

    The nmake ought to take 2-3 minutes, right?

    Use jom, it will parallelise your build, nmake is sequential.


Log in to reply