diff --git a/Knot.files b/Knot.files
index ab823637f9a139d368ef2a2366aaca651eb8381e..f1c114598c01027bf433bc37d85364bcf506db79 100644
--- a/Knot.files
+++ b/Knot.files
@@ -23,6 +23,7 @@ src/contrib/lmdb/lmdb.h
 src/contrib/lmdb/mdb.c
 src/contrib/lmdb/midl.c
 src/contrib/lmdb/midl.h
+src/contrib/lmdb/mute_warnings.h
 src/contrib/macros.h
 src/contrib/mempattern.c
 src/contrib/mempattern.h
diff --git a/src/contrib/Makefile.inc b/src/contrib/Makefile.inc
index 1663021107cfa6bfe0a4a2924845467de7fe8479..cef7e0b8ccd9fd979bbf70b80b2c7bebfc41335f 100644
--- a/src/contrib/Makefile.inc
+++ b/src/contrib/Makefile.inc
@@ -3,7 +3,8 @@ noinst_LTLIBRARIES += libcontrib.la
 libcontrib_la_CPPFLAGS = $(AM_CPPFLAGS) $(CFLAG_VISIBILITY)
 libcontrib_la_LDFLAGS  = $(AM_LDFLAGS) $(LDFLAG_EXCLUDE_LIBS)
 if !HAVE_LMDB
-libcontrib_la_LIBADD   = $(pthread_LIBS)
+libcontrib_la_CPPFLAGS += -include contrib/lmdb/mute_warnings.h
+libcontrib_la_LIBADD    = $(pthread_LIBS)
 endif !HAVE_LMDB
 
 EXTRA_DIST += \
@@ -67,7 +68,8 @@ libcontrib_la_SOURCES += \
 	contrib/lmdb/lmdb.h			\
 	contrib/lmdb/mdb.c			\
 	contrib/lmdb/midl.c			\
-	contrib/lmdb/midl.h
+	contrib/lmdb/midl.h			\
+	contrib/lmdb/mute_warnings.h
 endif !HAVE_LMDB
 
 if HAVE_LIBDNSTAP
diff --git a/src/contrib/lmdb/mute_warnings.h b/src/contrib/lmdb/mute_warnings.h
new file mode 100644
index 0000000000000000000000000000000000000000..c8d83291e2a8abfb998cd640239da238beaa3068
--- /dev/null
+++ b/src/contrib/lmdb/mute_warnings.h
@@ -0,0 +1,17 @@
+/*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma GCC diagnostic ignored "-Wshadow"