--- a/loudmouth/lm-asyncns-resolver.h
+++ b/loudmouth/lm-asyncns-resolver.h
@@ -20,6 +20,11 @@
 #define __LM_ASYNCNS_RESOLVER_H__
 
 #include <glib-object.h>
+#include <config.h>
+
+#ifdef HAVE_ASYNCNS
+#define freeaddrinfo(x) asyncns_freeaddrinfo(x)
+#endif
 
 #include "lm-resolver.h"
 
