diff --git a/src/3rdparty/zlib_dependency.pri b/src/3rdparty/zlib_dependency.pri
index 75dd2396f260a87ef581e65f96ffadd17067d0db..029bb9e63746a5faec66792d41afaddfac7e0037 100644
--- a/src/3rdparty/zlib_dependency.pri
+++ b/src/3rdparty/zlib_dependency.pri
@@ -1,7 +1,10 @@
 # zlib dependency satisfied by bundled 3rd party zlib or system zlib
 contains(QT_CONFIG, system-zlib) {
     if(unix|win32-g++*):LIBS_PRIVATE += -lz
-    else:               LIBS += zdll.lib
+    else {
+        isEmpty(ZLIB_LIBS): LIBS += zdll.lib
+        else: LIBS += $$ZLIB_LIBS
+    }
 } else {
     INCLUDEPATH +=  $$PWD/zlib
 }
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 792bdc47fbaeea0ce906f4bd4c725eb1a801c799..f031cfcf11cfef9e4b3cf7574d3ddbf5d59f779a 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -968,6 +968,8 @@ void Configure::parseCmdLine()
             dbusPath = QDir::fromNativeSeparators(configCmdLine.at(i));
         } else if (configCmdLine.at(i).startsWith("MYSQL_PATH=")) {
             mysqlPath = QDir::fromNativeSeparators(configCmdLine.at(i));
+        } else if (configCmdLine.at(i).startsWith("ZLIB_LIBS=")) {
+            zlibLibs = QDir::fromNativeSeparators(configCmdLine.at(i));
         }
 
         else if ((configCmdLine.at(i) == "-override-version") || (configCmdLine.at(i) == "-version-override")){
@@ -2563,9 +2565,10 @@ void Configure::generateOutputVars()
         qmakeVars += dbusPath;
     if (dictionary[ "SQL_MYSQL" ] != "no" && !mysqlPath.isEmpty())
         qmakeVars += mysqlPath;
-
     if (!psqlLibs.isEmpty())
         qmakeVars += QString("QT_LFLAGS_PSQL=") + psqlLibs.section("=", 1);
+    if (!zlibLibs.isEmpty())
+        qmakeVars += zlibLibs;
 
     {
         QStringList lflagsTDS;
diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h
index 0ec4edebc7c1673e9c7c3bcdca4cf126c4bcac42..e6b15e03053347b4ef029fe44b83658bc9d9a409 100644
--- a/tools/configure/configureapp.h
+++ b/tools/configure/configureapp.h
@@ -147,6 +147,7 @@ private:
     QString dbusPath;
     QString mysqlPath;
     QString psqlLibs;
+    QString zlibLibs;
     QString sybase;
     QString sybaseLibs;