如何在 Qt 项目中包含 OpenSSL [英] How to Include OpenSSL in a Qt project
问题描述
我是 Qt 的新手,我已经用 Google 搜索过,但找不到足够详细的答案.
I'm new to Qt, I've done some Googleing and can't find a detailed enough answer.
我需要在基于 qmake 的 Qt 项目中使用 OpenSSL.我如何下载/安装/链接它,以便我可以只做一个包含语句并在我的代码中使用它的功能?
I need to use OpenSSL in my qmake-based Qt project. How do I go about downloading/installing/linking it so I can just do an include statement and use its functions in my code?
推荐答案
假设是 Windows,你可以从 Win32 OpenSSL 安装项目页面.您可以选择一种用于 64 位 Windows 开发或用于 32 位.只需运行安装程序,一切都将轻松完成.默认安装目录为:C:OpenSSL-Win32
在 Qt creator 中,如果您想将库链接到您的项目,您只需将此行添加到您的 .pro 文件(项目文件):
Assuming Windows, you can download its installation from Win32 OpenSSL Installation Project page. You can choose one for 64-bit windows developing or for 32-bit. Just run the setup and everything will be done easily. The default installation directory is : C:OpenSSL-Win32
In Qt creator, if you then want to link a library to your project you can just add this line to your .pro file(project file ) :
LIBS += -L/path/to -llibname
所以这是我们为这个库所做的(例如链接 ubsec.lib )
So here's what we do for this library( for example to link ubsec.lib )
LIBS += -LC:/OpenSSL-Win32/lib -lubsec
注意-L和-l.看这个问题.您甚至不需要在库名末尾指定 .lib.
Pay attention to -L and -l.See this question. You don't even need to specify .lib at the end of the library name.
要包含 .h 文件,请将这一行添加到您的 .pro 文件中:
For including .h files add this line to your .pro file :
INCLUDEPATH += C:/OpenSSL-Win32/include
之后,您可以包含这样的文件:
after that you can include a file like this :
#include <openssl/aes.h>
这篇关于如何在 Qt 项目中包含 OpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!