how to compile qt static with open ssl
-
ooops, this could be. how can i tell make to compile the 32 bit version of qt?
i used this -platform win32-g++
how can we make sure that openssl is 32 bits and not 64? -
i compiled openssl as follows
perl configure VC-WIN64A --release --prefix=T:\openssl\dll\x64\release -openssldir=T:\openssl\ssl nmake nmake test nmake install_sw //this will copy to the dll folder and to program files/openssl/include / headers nmake clean perl configure VC-WIN64A --debug --prefix=T:\openssl\dll\x64\debug -openssldir=T:\openssl\ssl nmake nmake install_sw nmake clean //release static perl configure VC-WIN64A no-shared --release --prefix=T:\openssl\lib\x64\release -openssldir=T:\openssl\ssl nmake nmake install_sw nmake clean perl configure VC-WIN64A no-shared --debug --prefix=T:\openssl\lib\x64\debug -openssldir=T:\openssl\ssl nmake nmake install_sw nmake clean
and compile Qt with nmake using visual studio 2019
-
How are you compiling Qt ?
What setup do you do in the terminal you use for the build ? -
I downloaded Openssl 32 from the following link
and compiled qt with the following configureset OPENSSL_HOME=C:\OpenSSL-Win32 ..\configure -static -debug-and-release -platform win32-msvc2019 -static-runtime -ssl -openssl -openssl-linked -I %OPENSSL_HOME%\include -L %OPENSSL_HOME%\lib -opensource -confirm-license -opengl desktop -release -sql-sqlite -strip -qt-zlib -static-runtime -plugin-sql-sqlite -sql-sqlite -make tools -make libs -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -optimize-size -no-feature-d3d12
Notice that i did not use OPENSSL_LIBS because it keeps failing. I tried OPENSSL_LIBS="-LC:\OpenSSL-Win32\lib -lssl -lcrypto" but it failed. May be i am making it wrong !
I used Qt 5.13. The content of my make file and the contents of my config log is herenow i created a simple qml application with hello label. When i run the application i get "can not find libssl-1_1.dll, same for crypto-1_1.dll". This means it is linked dynamically. When i copy those files beside the binary it works, but i want to link it statically.
I tried many combinations. I am compiling with vs 2019 compiler ? does it make a difference if i compile the application with MinGW although Qt is compiled with nmake?
-
You either have to copy the dlls in the same folder as your application or modify the
PATH
environment in the Run part of the Project panel of Qt Creator and add the folder where they are. -
but i don't want to deliver these files to the user? my try was to create a simple file that can be delivered to the user and that i uses TLS
-
Then you have to also build OpenSSL statically.
If you want to have a 100% fully static application, you have to build all your libraries and their dependencies as static. Note that this is nothing Qt specific.
-
As far as i understand, the file i downloaded from this link has a folder called lib inside it there is static where libcrypto.lib and libssl.lib and ossl_static.pdb exist. There is also another folder called engines-3.
Assume that these libraries are statically built. how can we link it to qt to compile it using these libraries.
This command failedOPENSSL_LIBS="-LC:\OpenSSL-Win32\lib -lssl -lcrypto"
please download the file to see its content.
could you please correct it? -
Here is a solution and feedback to the people searching in future for same issue using openssl 1.1.1+ and at
guys the problem is as follows:
1- to compile it as static, you must use -openssl-linked parameter
2- but we think normally because we use the following parameters config will find the libraries.
-I %OPENSSL_HOME%\include -L %OPENSSL_HOME%\lib
but although these parameters are configured but config does not find the libraries and prints out the following error. It seems that these parameters are necessary only to find the header files and not to find the librariesNone of [libssl.dll.a libssl.a ssl.dll.a ssl.a ssl.lib] found in [] and global paths. None of [libcrypto.dll.a libcrypto.a crypto.dll.a crypto.a crypto.lib] found in [] and global paths.
The solution to this is to add the path of these static libraries and openssl binary into your global PATH variable, this way it will find the .a libraries. I used Openssl 1.1.1
do the following for a quick test
where libssl.a
where opensslif you get an output, so you can be sure it will work.
-
@SherifOmran said in how to compile qt static with open ssl:
PATH
If you really need to change that variable, then do it only in the terminal you use to build your stuff. It's never a good idea to add the path to such sensitive libraries system wide as you might break unrelated applications.