Fix loading of libresolv when the .so file (not .so.2) isn't installed

glibc is nice to us and provides a #define with the actual name. On most
Linux systems, the .so file is installed only if the glibc-devel package
is installed. For all of us Qt developers, it's installed. But for end
users, it might not be.

Change-Id: Id455371db91a074befd3bcd071f285c725d7e7e5
Reviewed-by: Ian Monroe <imonroe@kde.org>
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Thiago Macieira 2013-10-04 15:23:54 -07:00 committed by The Qt Project
parent 704616605b
commit 6c5e6a030d
2 changed files with 26 additions and 4 deletions

View File

@ -52,6 +52,10 @@
#include <arpa/nameser_compat.h>
#include <resolv.h>
#ifdef __GNU_LIBRARY__
# include <gnu/lib-names.h>
#endif
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
@ -77,9 +81,16 @@ struct QDnsLookupStateDeleter
static void resolveLibrary()
{
QLibrary lib(QLatin1String("resolv"));
QLibrary lib;
#ifdef LIBRESOLV_SO
lib.setFileName(QStringLiteral(LIBRESOLV_SO));
if (!lib.load())
return;
#endif
{
lib.setFileName(QLatin1String("resolv"));
if (!lib.load())
return;
}
local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand"));
if (!local_dn_expand)

View File

@ -63,6 +63,10 @@
# include <resolv.h>
#endif
#ifdef __GNU_LIBRARY__
# include <gnu/lib-names.h>
#endif
#if defined (QT_NO_GETADDRINFO)
static QBasicMutex getHostByNameMutex;
#endif
@ -93,9 +97,16 @@ static res_state_ptr local_res = 0;
static void resolveLibrary()
{
#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_QNX)
QLibrary lib(QLatin1String("resolv"));
QLibrary lib;
#ifdef LIBRESOLV_SO
lib.setFileName(QStringLiteral(LIBRESOLV_SO));
if (!lib.load())
return;
#endif
{
lib.setFileName(QLatin1String("resolv"));
if (!lib.load())
return;
}
local_res_init = res_init_proto(lib.resolve("__res_init"));
if (!local_res_init)