how can I enable SSL in QT windows application? - c++

Qt requires open ssl libraries to be installed on system. In debian / ubuntu when I install open ssl using apt everything works. But when I compile my application in windows, SSL features are not available I can verify this by executing
QSslSocket::supportsSsl()
How do I make it work in windows? I downloaded and installed open ssl from http://www.slproweb.com/products/Win32OpenSSL.html but it still returns false.

So after long time I figured what the problem is:
These 2 libraries need to be in same folder as your executable OR in windows system folder (system32 I think):
libeay32.dll
ssleay32.dll
You will find them in \bin of your OpenSSL folder, since I copied these 2 libs there it works
IMPORTANT: When deploying to client computers, it's also necessary to install vcredist package that was used to compile these .dll which may differ from vcredist package needed to run the application itself. vcredist version depends on version of the libraries.

You have to add OpenSSL lib in your project. In windows Qt doesn't come with OpenSSL lib. (I think it's a legal issue). You can find OpenSSL developer libs in URI you posted. If you are compiling against 32bit framework, what you need to download is Win32 OpenSSL v1.0.1e
This is what I have in my project.
QT += core gui network
win32{
LIBS += -LC:/OpenSSL-Win32/lib -lubsec
INCLUDEPATH += C:/OpenSSL-Win32/include
}

As you figured out already, you were missing dlls. Here is more information
Check what version of ssl you need with
QSslSocket::sslLibraryBuildVersionString();
For ssl 1.0.x (qt<5.12.4) you are likely missing libeay32.dll and ssleay32.dll.
For ssl 1.1.x (qt>=5.12.4) binary compatibility broke (qt 5.12.4 released), so you might need libssl-1_1.dll and libcrypto-1_1.dll, and its dependencies capi.dll and dasync.dll.

Related

Do I need to install Mingw compiler components in Qt installation if i had already installed Mingw in my computer?

I installing Qt open source framework in my window 10 pc. I already downloaded Mingw compiler and installed it to write C/C++. Now I wanna learn QT framework. I using Qt online installer. I choice to download custom compoment. Do I need to selet mingw component to download if i had already installed?
Note that there's not just one MinGW distribution and version out there. You can check out the exact supported version per Qt release at https://wiki.qt.io/MinGW .
Anyhow, if you install the pre-built Qt binaries via the online installer, the matching MinGW version will automatically be installed for you, and will be registered in Qt Creator so that things just work. There is actually no official way to prevent this.

Qt project release ubuntu - error while loading shared libraries: libQt5Widgets.so.5

I want to release my project written with Qt to a Ubuntu / Linux user. If they try to execute the build release version they get this error message, because they have not installed Qt:
error while loading shared libraries: libQt5Widgets.so.5:
cannot open shared object file: No such file or directory
Is there a way to add all the libraries such as libQt5Widgets.so.5 to the folder where the executable is, just like under Windows with qt.conf, where you can specify the Plugins folder?
Try this
sudo apt-get install libqt5widgets5
One solution could be:
export LD_LIBRARY_PATH=/path/to/dir/with/libs:$LD_LIBRARY_PATH
But a proper solution would be to install QT libraries in system and/or package your app for Ubuntu (in your case).
I had recently updated the Android tools via the SDK manager when I saw this error.
Re-install the SDK tools to fix. That is what worked for my machine.
It may be simplest to package the project using Ubuntu's package management system. The Qt dependency will then be automatically installed by the package manager when your project is installed. That'd be the best way to go about it, as long as there is a version of Qt 5 available in Ubuntu's package repository. It'll save you a whole lot of grief.

Error in running Qt created executable on Ubuntu

I have written a code that runs successfully on a ubuntu machine having Qt installed but when I'm trying to run the executable on another ubuntu machine that don't have Qt I am getting this error:
error while loading shared libraries: libQt5Widgets.so.5
Since you have a shared build, you need the required shared Qt libraries on your system.
Alternatively if you want to build a standalone executable then you will have to compile it statically.
Following link maybe helpful:
How to make binary distribution of Qt application for Linux
As is clear, the required Qt libraries are not installed on the other machine, you will need to install Qt libraries first.
The standard procedure followed on Linux, is to create a package (Debian, rpm, pacman etc.) Since you are using Ubuntu, you should create a Debian package with libqt5gui5 mentioned as dependency, so when you install the package, Qt libraries are automatically downloaded and installed if necessary.

Error Creating SSL Context - Qt

I tried everything mentioned in this Question
but nothing worked.
The binary works fine on Windows 64-bit, but almost always shows the error
Error Creating SSL Context()
on Windows 32-bit. I tried the demo http client example.
At last, I found the solution. I was downloading dll's from a dll website. You need to take these libraries
- libeay32.dll
- libssl32.dll
- ssleay32.dll
from this website here Win32 OpenSSL v1.0.2 file for 32 bit if you are using MSVC++ compiler
After installation of the above binary, copy the above three dll's in the the directory containing your binary file.
I recommend this source for OpenSSL Windows binaries. These binaries have no external dependencies and tested with 32-bit and 64-bit Qt5.
Update: OpenSSL 1.0 and 1.1 are not binary- and API-compatible. As of Qt 5.12 (certainly 5.12.4) version 1.1 seems the default OpenSSL backend in Qt, although I hear it can be configured to keep using 1.0.
I'm testing this source for Windows OpenSSL 1.1 builds, no problems so far: https://bintray.com/vszakats/generic/openssl

Problems deploying Qt application using QtWebkit and OpenSSL on Linux

I have an application that I'm writing that uses QtWebkit and OpenSSL which deploys fine on Mac OS X 10.6 or higher and Windows XP SP2 or higher, but I'm having problems deploying the application on Linux (Unix) platforms. I've made a tarball of the application including a bin and lib folder and set the LD_LIBRARY_PATH to the local lib folder and included all Qt and external libraries on the lib folder. When my application tries to load webpages using SSL, it can't resolve the functions necessary for SSL. I've gotten deployment to work if I install the development libraries for OpenSSL on my target machine, but I'd like to have my application use the release libraries for OpenSSL on the user's machine. Am I missing something in my pro file?
Here's the relevant code from my pro file:
QT += core gui webkit network sql xml
unix:LIBS += -L$$PWD/../../../usr/local/lib/ -lqjson
unix:INCLUDEPATH += $$PWD/../../../usr/local/include
unix:DEPENDPATH += $$PWD/../../../usr/local/include
macx:LIBS += -L$$PWD/../../../usr/local/lib/ -lqjson
macx:INCLUDEPATH += $$PWD/../../../usr/local/include
macx:DEPENDPATH += $$PWD/../../../usr/local/include
win32:LIBS += -L C:/qjson/lib/ -llibqjson
win32:INCLUDEPATH += C:/qjson/include
win32:DEPENDPATH += C:/qjson/include
I'm considering making a deb and rpm package to resolve dependency problems, but I'd rather not make several packages for each available Linux distribution. This is why I went the tarball method first. I'm open to suggestions.
Maybe you didn't compile Qt with support for SSL. Read about it here