Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Official guide for compiling static QT with SSL support (possibly using OpenSSL toolkit already included in QT)
Hi, i'm getting crazy tryin' to compile a static QT build with SSL support.
Is there an official guide, a tutorial, something, or someone that would give me a hint?
i am able to build if i don't include any ssl options at config time, but if i do, it builds disabling it bc of the missing prerequisites (and i have the files)
What are the exact errors you are getting ?
How did you get OpenSSL on your machine ?
Which compiler are you using ?
configure outputs a laconic "ERROR: Feature 'openssl-runtime' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl_headers' failed."
(i'm using mingw)
Until now i was using a binary build from slproweb, now i discovered that they only supports mingw using 32bit version of their build; i am so lost that at that point i'd prefere building it myself but it seems like it's rather complicated. That's why i was hoping for an already written tutorial to obtain a static Qt build with ssl...
You should be able to download OpenSSL through the Qt online installer.
cmd /c "configure.bat -v -static -opensource -confirm-license -debug-and-release -platform win32-g++ -prefix $QtDir -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -openssl -I
"-llibssl -llibcrypto" -make libs -nomake tools -nomake examples -nomake tests "
so, using the "embedded" openssl frameworks, still gives me
"ERROR: Feature 'openssl-runtime' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl_headers' failed." without any other explanation even if i'm running config in verbose mode.
I'l like to know what's missing, if it cannot finds the path or anything, but -v doesn't gives me hints
same if i compile using -openssl-linked, it just says "ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl' failed."
i want to have a ssl static build that i compile with, so i get just one .exe and everything inside
Shouldn't that be
artwaw last edited by
@Giovanni-R try downloading ssl binaries precompiled with mingw or compile them from sources, those provided by Qt are compiled with MSVC. I don't say this is exactly the reason but I would definitely try.
@artwaw hi! any hint on where i could find precompiled mingw builds?
i would happily avoid compiling also OpenSSL but if it's needed i will...
artwaw last edited by artwaw
@Giovanni-R I had, some time ago, an issue where my software was working on some machines and on some machines not (login to external service was failing). It was very frustrating as all libs were in place and on some it was indeed working... I finally did my due diligence and found out, that some of the machines had vcredist libs and those were working fine, some others had not and those were failing. Then I checked the Qt libraries and the truth came out.
When you go to the https://wiki.openssl.org you'll undoubtedly find the list of mirrors. I needed 184.108.40.206 (1.1.1.d) then and I am not sure which ones you'll need (info about OpenSSL compatibility per version should be somewhere in docs as this is where I took it from). I used this site to obtain binaries: https://github.com/curl/curl-for-win#binary-package-downloads
You will need curl, please take time to read how to obtain binaries in required version.
Of course, you're most welcome to pursue any other source of binaries you find trustworthy, there is a few.
@SGaist did i already say i am lost? :)
i will try with -lssl -lcrypto
tried, no luck, same error
There are test logs generated, you should be able to find there the exact error regarding OpenSSL.
Trying source 0 (type inline) of library openssl_headers ... openssl/ssl.h not found in  and global paths. openssl/opensslv.h not found in  and global paths. => source produced no result. test config.qtbase_network.libraries.openssl_headers FAILED Trying source 0 (type makeSpec) of library network ... => source accepted. loaded result for config test config.qtbase_network.tests.getifaddrs + cd /d C:\Qt\Static5152\src\qt-everywhere-src-5.15.2\config.tests\getifaddrs && C:\Qt\Static5152\src\qt-everywhere-src-5.15.2\qtbase\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" "QMAKE_USE += network" "QMAKE_LIBS_NETWORK = -lws2_32" C:/Qt/Static5152/src/qt-everywhere-src-5.15.2/config.tests/getifaddrs + cd /d C:\Qt\Static5152\src\qt-everywhere-src-5.15.2\config.tests\getifaddrs && set MAKEFLAGS=& mingw32-make > g++ -c -fno-keep-inline-dllexport -O2 -w -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_STATIC_BUILD -I. -IC:\Qt\Static5152\src\qt-everywhere-src-5.15.2\qtbase\mkspecs\win32-g++ -o main.o main.cpp > main.cpp:3:10: fatal error: sys/socket.h: No such file or directory > #include <sys/socket.h> > ^~~~~~~~~~~~~~
I want to focus on that part of the config.log... (it's taken from a powershell script so it has some escaping)
"openssl/ssl.h not found in  and global paths.
openssl/opensslv.h not found in  and global paths."
config line is
configure.bat -opensource -confirm-license -static -debug-and-release -platform win32-g++ -prefix $QtDir -openssl-linked -I 'C:\Qt\Tools\OpenSSL\src\include\openssl' -L 'C:\Qt\Tools\OpenSSL\Win_x64\lib' OPENSSL_LIBS=`"-lssl -lcrypto`" -skip webengine -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -sql-sqlite -make libs -nomake tools -nomake examples -nomake tests
i tried with -I C:\Qt\Tools\OpenSSL\src\include also but same result and i can tell you for sure that in C:\Qt\Tools\OpenSSL\src\include\openssl there is both opensslv.h and ssl.h (ssl toolkit from qt installer).
So why the config is not able to find them?
main.cpp:3:10: fatal error: sys/socket.h: No such file or directory
i don't feel like that one is usual. Am i wrong?
I mean it's crazy to me that i have to be stopped 2wks by stuff like that :/
But keep in mind that you should always do a complete rebuild (without old build artefacts)!
Nuking the whole folder and starting again seems to have fixed the issue (or at least, it seems like now it finds the headers that were missing) but now it's not even starting to compile
"mingw32-make: *** No targets specified and no makefile found. Stop.
mingw32-make: *** No rule to make target 'install'."
This is the config.log
It misses random stuff, that was not missing last time i compiled with the same configure...i don't know if that's just me or the whole thing is utterly unusable (maybe it's Windows..i don't know...but still...)
@Giovanni-R Did you also run configure again?
Bonnie last edited by Bonnie
This should pass the config test (no need to add -I and -L for openssl, and need to clear the build folder before running configure again):
-openssl-linked OPENSSL_PREFIX="C:\Qt\Tools\OpenSSL\Win_x64" OPENSSL_LIBS="-llibssl -llibcrypto"
@Bonnie finger crossed, QSslSocket::supportsSsl(); using the build compiled with OPENSSL_PREFIX seems to return true, so i'm pretty optimistic about the thing that it should work properly!
I don't know if i'm finally out of that nightmare but a huge THANKS in any case