Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Include OpenSSL in a Qt project

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

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?

like image 811
Mitch Avatar asked Feb 04 '13 05:02

Mitch


People also ask

Does Qt use OpenSSL?

Qt binary installers include the OpenSSL libraries used by QtNetwork. However, those are not automatically deployed with applications that are built with Qt. Import and export restrictions apply for some types of software, and for some parts of the world.

How compile C++ Qt?

Here are the basic steps for building Qt on any platform: Download the source code archive. Extract the source code into a working directory. Install the required development packages and other build dependencies for Qt.


Video Answer


2 Answers

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

So here's what we do for this library( for example to link ubsec.lib )

LIBS += -LC:/OpenSSL-Win32/lib -lubsec

Pay attention to -L and -l.See this question. You don't even need to specify .lib at the end of the library name.

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>
like image 166
s4eed Avatar answered Sep 20 '22 15:09

s4eed


From George at Unable to use AES files of OpenSSL in Qt Creator:

If this is on Linux, add the following into your .pro file:

PKGCONFIG += openssl 

It will handle all necessary header paths, compile-linker options and the libraries.

And make sure you have the openssl-devel package installed in your system.

like image 32
jww Avatar answered Sep 19 '22 15:09

jww