Try harder to locate external OpenSSL libraries on win32

When OpenSSL is built using MSVC then the library names are
named ssleay32.dll and libeay32. However, when OpenSSL is built
with GCC then different library names are used like libssl-10.dll
and libcrypto-10.dll (depending on the version of OpenSSL used)

Change-Id: Icb79a5f82d2a511752bfc904f53a58423ce4b86b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Peter Hartmann <phartmann@rim.com>
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Erik van Pienbroek 2013-02-06 22:08:40 +01:00 committed by The Qt Project
parent 916f0ff663
commit 3798b129c0

View File

@ -447,28 +447,46 @@ static QStringList findAllLibCrypto()
# endif
#ifdef Q_OS_WIN
static bool tryToLoadOpenSslWin32Library(QLatin1String ssleay32LibName, QLatin1String libeay32LibName, QPair<QSystemLibrary*, QSystemLibrary*> &pair)
{
pair.first = 0;
pair.second = 0;
QSystemLibrary *ssleay32 = new QSystemLibrary(ssleay32LibName);
if (!ssleay32->load(false)) {
delete ssleay32;
return FALSE;
}
QSystemLibrary *libeay32 = new QSystemLibrary(libeay32LibName);
if (!libeay32->load(false)) {
delete ssleay32;
delete libeay32;
return FALSE;
}
pair.first = ssleay32;
pair.second = libeay32;
return TRUE;
}
static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()
{
QPair<QSystemLibrary*,QSystemLibrary*> pair;
pair.first = 0;
pair.second = 0;
QSystemLibrary *ssleay32 = new QSystemLibrary(QLatin1String("ssleay32"));
if (!ssleay32->load(false)) {
// Cannot find ssleay32.dll
delete ssleay32;
return pair;
// When OpenSSL is built using MSVC then the libraries are named 'ssleay32.dll' and 'libeay32'dll'.
// When OpenSSL is built using GCC then different library names are used (depending on the OpenSSL version)
// The oldest version of a GCC-based OpenSSL which can be detected by the code below is 0.9.8g (released in 2007)
if (!tryToLoadOpenSslWin32Library(QLatin1String("ssleay32"), QLatin1String("libeay32"), pair)) {
if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-10"), QLatin1String("libcrypto-10"), pair)) {
if (!tryToLoadOpenSslWin32Library(QLatin1String("libssl-8"), QLatin1String("libcrypto-8"), pair)) {
tryToLoadOpenSslWin32Library(QLatin1String("libssl-7"), QLatin1String("libcrypto-7"), pair);
}
}
}
QSystemLibrary *libeay32 = new QSystemLibrary(QLatin1String("libeay32"));
if (!libeay32->load(false)) {
delete ssleay32;
delete libeay32;
return pair;
}
pair.first = ssleay32;
pair.second = libeay32;
return pair;
}
#else