Qt 5.6.2 on Windows, static build with openssl 1.0.2L and MinGW492_32
-
Hi,
I've successfully build a static version of Qt 5.6.2 with the script windows-build-qt-static.ps1 from this URL : http://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW
I added some build options to disable some Qt modules I don't need.cmd /c "configure.bat -static -debug-and-release -platform win32-g++ -target xp -no-directwrite -prefix $QtDir -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -no-opengl -no-openvg -no-angle -qt-sql-sqlite -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests -skip qtwebengine -skip qtwebview -skip qtquickcontrols -skip qtquickcontrols2 -skip qtlocation -skip qtscript"
I get this message but it seems to work on Windows XP. Is it normal with MinGW?
WARNING: Cannot use Windows Kit 8 to build Qt for Windows XP. WARNING: Windows SDK v7.1A is recommended.
I am able to build a static application, only one executable file. It works well.
Now, my application need to download files from https.
So, I need to add the openssl support to my static build of Qt so that my application doesn't need to be released with an openssl dll.
I downloaded and installed the precompiled openssl version 1.0.2L from this URL : https://slproweb.com/products/Win32OpenSSL.html
I added these options to the script windows-build-qt-static.ps1 :-openssl -I c:\OpenSSL-Win32\include -L c:\OpenSSL-Win32\lib\MinGW
The build of Qt seems to complete without any error.
I build my application.
I run it, and I get an error saying it depends on Qt5Core.dll.Is there something bad with the openssl options I added to build Qt?
Best regards,
Matthieu -
Hi and welcome to devnet,
Did you properly re-build Qt from scratch after adding OpenSSL to the mix ?
-
Thanks :)
Yes, I deleted the source directory and extracted the source archive again, so the configure was run from a clean state. -
Do you have several version of Qt installed in parallel ?
If so, check the Kit you are using, it might be using the wrong version of Qt.
-
hi,
I have only one version installed.
I realized that I didn't use the right Qt prompt, I was in dynamic environment.
But, I still have problems in static environment.
Do I need to link to -lssl, -lcrypto -llibeay32 -lssleay32, in the OPENSSL_LIBS ??I don't really understand the difference between -openssl and -openssl-linked.
Is it possible to link statically openssl when I build my project instead of link to the Qt build?
Best regards, -
When I execute in debug mode my application, I get this error :
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_callback qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated Auto configuration failed 5672:error:02001015:system library:fopen:Is a directory:.\crypto\bio\bss_file.c:126:fopen('d:/test/openssl098kvc6/openssl.cnf','rb') 5672:error:2006D002:BIO routines:BIO_new_file:system lib:.\crypto\bio\bss_file.c:131: 5672:error:0E078002:configuration file routines:DEF_LOAD:system lib:.\crypto\conf\conf_def.c:199: QMutex: destroying locked mutex
What I need to do to fix this, please?
-
It looks like you didn't explicitly state that you wanted OpenSSL to be linked to Qt (
-openssl-linked
) so it tries to load the library but it can't find it. One way to check that is to go the Run part of the Project panel and modify the PATH environment variable there to include the path to the OpenSSL .dlls. -
So I need to build with -openssl-linked.
But do I need to add some build options? like -lssl -lcrypto -lssleay -llibeay32?In dependency walker, there is no openssl dll.
-
Because by default Qt loads the .dll it doesn't link against it.
-
Is it possible to build qt without openssl dll dependencies?
I don't know if I am on the wrong way. -
Yes, use
-openssl-linked
and a static build of OpenSSL. -
Hello,
To answer myself, I found the solution and here is how I did it.First, I build openssl in static mode. You need to install active perl, mingw-get-setup.exe and mysys-1.0.11.exe (i'm not sure if this one is really required). I downloaded the openssl-1.0.2l sources and I followed this guide: http://www.stringcat.com/company_blog/2015/12/07/compiling-openssl-on-windows-mingw32/
To build, start mingw, go to the openssl root directory and run:perl Configure mingw no-shared
At the end, I created a subdirectory named lib in the openssl dir and copied libssl.a and libcrypo.a into it.
To build Qt, I used this script:
https://sourceforge.net/p/qtlmovie/code/ci/v1.2.16/tree/build/windows-build-qt-static.ps1?format=raw
I added these parameters to the configure line:-openssl-linked -I c:\openssl\include -L c:\openssl\lib
In this script, I added a pause between configure and make to be able to modify a file juste before the compilation phase. Just write a new line below configure and write: pause.
Execute the script.
When the script is paused, open the qtbase/mkspecs/qmodule.pri file and change:
-lssleay32 -llibeay32
to:
-lssl -lcrypto -lgdi32
and save the file.
Press any key to continue the pause. Wait, enjoy.
I think this is a bug in the Qt build system, with openssl-linked we shouldn't have linked to *eay32...
-
IIRC, it's Windows VS *nix naming issue with OpenSSL so not a bug.
-
So, it's a bug, for me :D