简体   繁体   English

如何在 Windows 10 上为 Qt 正确设置 OpenSSL?

[英]How to properly setup OpenSSL for Qt on Windows 10?

I've downloaded and installed OpenSSL from this link: http://slproweb.com/products/Win32OpenSSL.html我已经从这个链接下载并安装了 OpenSSL: http : //slproweb.com/products/Win32OpenSSL.html

Then I added the following line to my .pro file:然后我将以下行添加到我的 .pro 文件中:

LIBS += -LC:/OpenSSL-Win32/lib -llibcrypto -llibssl

I can confirm QT is able to link the libs because if I put a random letter on their name it fails the build saying that said lib was not found我可以确认 QT 能够链接库,因为如果我在他们的名字上放一个随机字母,它会导致构建失败,说没有找到所说的库

Then I copied "libcrypto-1_1.dll" and "libssl-1_1.dll" from the OpenSSL bin folder to my application folder.然后我将“libcrypto-1_1.dll”和“libssl-1_1.dll”从 OpenSSL bin 文件夹复制到我的应用程序文件夹。

I added #include <QSslSocket> to my file, but when I call QSslSocket::supportsSsl() it always return false.我将#include <QSslSocket>添加到我的文件中,但是当我调用QSslSocket::supportsSsl()它总是返回 false。 What I'm doing wrong?我做错了什么?

Note: I'm clearing the project between builds to assure QT is using the lastest changes注意:我正在清除构建之间的项目以确保 QT 使用最新的更改

Problem solved by following this step:问题通过以下步骤解决:

The OpenSSL libraries are looked up first in the directory of the executable, then in the Windows System directory (usually C:\\Windows\\system32), and finally in all directories listed in the PATH environment variable. OpenSSL 库首先在可执行文件的目录中查找,然后在 Windows 系统目录(通常是 C:\\Windows\\system32)中,最后在 PATH 环境变量中列出的所有目录中查找。

Once I copied the dlls to system32 folders it started working (even though I had them on PATH variable AND executable folder)一旦我将 dll 复制到 system32 文件夹,它就开始工作(即使我将它们放在 PATH 变量和可执行文件夹中)

More info can be found here: https://doc.qt.io/qt-5/windows-requirements.html更多信息可以在这里找到: https : //doc.qt.io/qt-5/windows-requirements.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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