简体   繁体   中英

OpenSSL in Qt5 on Windows

I'm trying to link openssl with qt5.12 but the result differs when running executable from qt and from command line. I use QSslSocket::supportsSsl(), QSslSocket::sslLibraryVersionString() and QSslSocket::sslLibraryBuildVersionString() to observe the results. When running exe from qt i get the following output respectively true OpenSSL 1.1.1d 10 Sep 2019 OpenSSL 1.1.1k 25 Mar 2021 and for command line false "" OpenSSL 1.1.1k 25 Mar 2021 . The exe is compiled with msvc 2017 64 bit. What could be the problem and where does qt get that library from?

Using listdlls tool i managed to find the name and location of openssl DLLs. They're libssl-1_1-x64.dll and libcrypto-1_1-x64.dll and located in %QT_INSTALL_PATH%/Tools/QtCreator/bin . Copying those DLLs to the build folder of the project solved the issue.

QtCreator used build environment which is apparently the default environment and can be found in Projects -> Run . It sets a number of environment variables, and in my case exactly, it updated the PATH variable adding the path of QtCreator bin folder.

Qt doesn't ship SSL libraries by default, you need to install them manually, to be sure that you have compatible SSL libraries Install OpenSSL XXX Toolkit from Qt Maintenance Tool then in <Qt directory>/Tools/OpenSSL you will find your OpenSSL packages with binaries. 在此处输入图像描述

In order to fully ship Windows Qt application to the end-users, please study https://doc.qt.io/qt-5/windows-deployment.html closely

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM