--- a/configure.ac
+++ b/configure.ac
@@ -90,19 +90,31 @@ AC_CHECK_LIB([krb5], [krb5_cc_initialize
 AC_CHECK_LIB([uuid], [uuid_unparse], [],
 	AC_MSG_ERROR([Install UUID library development files]))
 
+AC_LANG(C)
 # Check version of libdns
 AC_MSG_CHECKING([libdns version])
-AC_TRY_RUN([
+AC_RUN_IFELSE([AC_LANG_PROGRAM([
 #include <stdio.h>
 #include <dns/version.h>
-int main(void) {
-	printf("%d\n", dns_libinterface);
-	return 0;
-}],[LIBDNS_VERSION_MAJOR=`./conftest$ac_exeext`
+],[ printf("%d\n", dns_libinterface) ])], [
+    LIBDNS_VERSION_MAJOR=`./conftest$ac_exeext`
+    AC_DEFINE_UNQUOTED([LIBDNS_VERSION_MAJOR], [$LIBDNS_VERSION_MAJOR],
+    [Define libdns version])], [
+    AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <dns/version.h>
+]],[[
+	unsigned major, minor, patch, scanned;
+	/* emulate dns_libinterface from minor and patch version */
+        scanned = sscanf(dns_version, "%u.%u.%u", &major, &minor, &patch);
+        printf("%02d%02d\n", minor, patch);
+	return !(scanned == 3 && major == 9);
+    ]])], [
+    LIBDNS_VERSION_MAJOR=`./conftest$ac_exeext`
     AC_DEFINE_UNQUOTED([LIBDNS_VERSION_MAJOR], [$LIBDNS_VERSION_MAJOR],
     [Define libdns version])],
-[AC_MSG_ERROR([Can't obtain libdns version.])],
-[AC_MSG_ERROR([Cross compiling is not supported.])]
+    [AC_MSG_ERROR([Can't obtain libdns version.])])
+], [AC_MSG_ERROR([Cross compiling is not supported.])]
 )
 
 dnl isc_errno_toresult() was not available in older header files
--- a/src/fwd_register.c
+++ b/src/fwd_register.c
@@ -6,6 +6,7 @@
 #include <isc/util.h>
 #include <dns/name.h>
 
+#include "config.h"
 #include "rbt_helper.h"
 #include "fwd_register.h"
 #include "util.h"
@@ -35,7 +36,11 @@ fwdr_create(isc_mem_t *mctx, fwd_registe
 	ZERO_PTR(fwdr);
 	isc_mem_attach(mctx, &fwdr->mctx);
 	CHECK(dns_rbt_create(mctx, NULL, NULL, &fwdr->rbt));
+#if LIBDNS_VERSION_MAJOR >= 1600
+	(void)isc_rwlock_init(&fwdr->rwlock, 0, 0);
+#else
 	CHECK(isc_rwlock_init(&fwdr->rwlock, 0, 0));
+#endif
 
 	*fwdrp = fwdr;
 	return ISC_R_SUCCESS;
--- a/src/zone_register.c
+++ b/src/zone_register.c
@@ -12,6 +12,7 @@
 #include <dns/result.h>
 #include <dns/zone.h>
 
+#include "config.h"
 #include "fs.h"
 #include "ldap_driver.h"
 #include "log.h"
@@ -115,7 +116,12 @@ zr_create(isc_mem_t *mctx, ldap_instance
 	ZERO_PTR(zr);
 	isc_mem_attach(mctx, &zr->mctx);
 	CHECK(dns_rbt_create(mctx, delete_zone_info, mctx, &zr->rbt));
+#if LIBDNS_VERSION_MAJOR >= 1600
+	/* Never fails on BIND 9.16, even it if returns value */
+	(void)isc_rwlock_init(&zr->rwlock, 0, 0);
+#else
 	CHECK(isc_rwlock_init(&zr->rwlock, 0, 0));
+#endif
 	zr->global_settings = glob_settings;
 	zr->ldap_inst = ldap_inst;
 
