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 -ssl
, -openssl-linked
, -openssl
and what each means. Also, if one should use -L/path/to/libs/static -l library1 -l library2
vs using the OPENSSL_HOME
env variable and specify the path to headers & static / linked libraries, etc
Please note:
Ideally, in compiling, specific instructions for libraries would be required such as OpenSSL v1.0.2
or OpenSSL v1.1
and the qmake
arguments 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
-l
and/or-L
to the various paths (.lib
), (.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.
See Question&Answers more detail:os