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)
any hint/help/guide/link?
Thanks
-
Hi,
What are the exact errors you are getting ?
How did you get OpenSSL on your machine ?
Which compiler are you using ? -
hi!
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.
-
compiling with
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
"C:\Qt\Tools\OpenSSL\src\include
" -L"C:\Qt\Tools\OpenSSL\Win_x64\lib
" OPENSSL_LIBS="-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
-lssl -lcrypto
? -
@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.
-
@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 1.1.1.4 (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.
-
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?
And also...
main.cpp:3:10: fatal error: sys/socket.h: No such file or directory
#include <sys/socket.h>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 :/ -
@Giovanni-R said in Official guide for compiling static QT with SSL support (possibly using OpenSSL toolkit already included in QT):
-I 'C:\Qt\Tools\OpenSSL\src\include\openssl'
Change to
-I 'C:\Qt\Tools\OpenSSL\src\include
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'."https://pastebin.com/XbrWwffA
This is the config.logIt 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 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