【问题标题】:How to implement OpenSSL in Qt?如何在 Qt 中实现 OpenSSL?
【发布时间】:2017-09-09 03:22:12
【问题描述】:

尝试在我的 Qt 项目中使用 OpenSSL,这是我的环境:

  • 操作系统:Win7 32位
  • Qt:Qt Creator 4.2.1 社区
  • Qt 工具包:Qt_5_8_0_MSVC2015_32bit2
  • Openssl:Win32 OpenSSL v1.1.0e,下载表格this site

我试图在我的代码中使用include <openssl/evp.h>,但是,当我在 main.cpp 中添加#include <openssl/evp.h> 并构建时,Qt Creator 显示以下错误:D:\QtProjects\dialogs\findfiles\main.cpp:50: error: C1083: 'openssl/evp.h':No such file or directory

我已经按照这个问题的说明进行操作:How to Include OpenSSL in a Qt project

我的 .pro 文件如下所示:

QT += widgets

HEADERS       = window.h
SOURCES       = main.cpp \
                window.cpp

# install
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/dialogs/findfiles
INSTALLS += target

# for openssl - I added these 2 lines
LIBS += -LC:/OpenSSL-Win32/lib -llibcrypto
INCLUDEPATH += C:/OpenSSL-Win32/include

请帮我解决这个问题。

【问题讨论】:

  • C:/OpenSSL-Win32/include/openssl/evp.h 存在吗?
  • 是的,它存在。
  • 想知道我的问题是否与我在 D:Qt 中安装 Qt 而不是 C:Qt...
  • 这应该不是问题。尝试将C:/xxx 更改为C:\xxx
  • 将 INCLUDEPATH 从 C:/xxx 更改为 C:\xxx,仍然出错。

标签: c++ windows qt ssl openssl


【解决方案1】:

将此作为答案发布,因为我很确定我想通了。

您必须在构建之前运行 Qmake,否则您的 pro 文件中的更改不会受到影响。由于 Qmake 正在将您的 pro 文件编译成 makefile

构建->运行 QMake

为我的 OpenSSL 库工作。

祝你好运!

【讨论】:

  • 是的,你想通了!我现在可以在我的 Qt 项目中使用 openssl。万分感谢~
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-10
  • 2013-01-18
  • 1970-01-01
  • 1970-01-01
  • 2011-03-21
相关资源
最近更新 更多