如何在Qt项目中包含OpenSSL [英] How to Include OpenSSL in a Qt project

查看:658
本文介绍了如何在Qt项目中包含OpenSSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Qt的新手,我做了一些Google搜索,却找不到足够详细的答案.

I'm new to Qt, I've done some Googleing and can't find a detailed enough answer.

我需要在基于qmake的Qt项目中使用OpenSSL.我该如何下载/安装/链接它,以便仅执行一个include语句并在其代码中使用其功能?

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位Windows选择一个.只需运行安装程序,一切都将轻松完成.默认安装目录为: C:\ OpenSSL-Win32
Qt创建器中,如果您想将库链接到您的项目,则可以将此行添加到.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 <​​/strong>.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆