Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
how to statically compile Qt using MinGW compiler and SSL support
CybeX last edited by
How to statically compile Qt with OpenSSL support on Windows (with MinGW compiler)
The desired 'outcome' of this Qt build is to build and ship a portable Qt application with built-in SSL support.
So this is an age old problem with a multitude of questions on this topic, yet very few solutions exist that solves the problem. Some of these questions (and problems):
- QT https SSL support for static QT static program build - getting 'Protocol “https” is unknown'
- about compiling openssl inside qt application
- Build Qt static from source enabling OpenSSL support
- Compile static version of QT + OpenSSL Support
- how to compile qt static with open ssl
- Compiling static for Windows with OpenSSL
there are many more
and some of my own questions (using OpenSSL v1.1.1d & Qt 5.13 with MinGW ):
- Statically compiled Qt 5.13.1 with OpenSSL 1.1.1d producing QSslSocket::connectToHostEncrypted: TLS initialization failed
- Create a standalone binary using Qt with OpenSSL support
- Static OpenSSL *.a libraries not linked target binary (using Statically Compiled Qt with SSL)
- Static compile Qt 5.13.1 with -openssl-linked using MinGW (Windows 10)
Most of these questions do not have answers, and those answers provided (obviously) did not help in compiling, due to some error output or simply OpenSSL was never linked (built into the portable/binary application), or many other errors.
Further, there appears to be alot of confusion about using
-openssland what each means. Also, if one should use
-L/path/to/libs/static -l library1 -l library2vs using the
OPENSSL_HOMEenv variable and specify the path to headers & static / linked libraries, etc
Ideally, in compiling, specific instructions for libraries would be required such as
OpenSSL v1.1and the
qmakearguments in building a static Qt with those specific libraries in addition to things that should be considered during the build process.
What does Qt say?
Qt has provide some help in the form of these 2 posts:
- Building a static Qt for Windows using MinGW with a Powershell script which does compile Qt statically using MinGW, but adding the various combinations (and permutations) of OpenSSL libraries
-Lto the various paths (
.a), header files, etc simply did not work
- Compiling OpenSSL with MinGW
The aim of this question is to give a detailed explanation and step-wise method in allowing those who need to compile a static Qt version with SSL some support and direction.
This is an unnatural "question", but having seen so many questions with no/very few solutions for cherrypicked cases in each specific question makes a general solution very difficult to obtain.
I am posting this question in hopes of a general solution being made available that could benefit all.