diff --git a/configure.ac b/configure.ac
index 402c399..20555ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ AC_CONFIG_SRCDIR(src/gloox.cpp)
 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
 
 dnl create a config.h file (Automake will add -DHAVE_CONFIG_H)
-AM_CONFIG_HEADER(config.h.unix)
+AC_CONFIG_HEADER(config.h.unix)
 
 AC_SUBST(VERSION)
 
@@ -326,8 +326,8 @@ AC_MSG_RESULT($getaddrinfo)
 
 dnl Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(unistd.h strings.h errno.h arpa/nameser.h)
-AC_CHECK_FUNCS(setsockopt,,[AC_CHECK_LIB(socket,setsockopt)])
+AC_CHECK_HEADERS(unistd.h wchar.h string.h cstring.h strings.h errno.h arpa/nameser.h)
+AC_CHECK_FUNCS(setsockopt,,[AC_CHECK_LIB(network,setsockopt)])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
diff --git a/src/connectiontcpbase.cpp b/src/connectiontcpbase.cpp
index 2da70c0..b28f8e8 100644
--- a/src/connectiontcpbase.cpp
+++ b/src/connectiontcpbase.cpp
@@ -10,7 +10,17 @@
   This software is distributed without any warranty.
 */
 
+#if defined HAVE_STRING_H
+#include <string.h>
+#endif
+ 
+#if defined HAVE_WCHAR_H
+#include <wchar.h>
+#endif
 
+#if __GNUC__ > 3
+#include <cstring>
+#endif
 
 #include "gloox.h"
 
diff --git a/src/connectiontcpserver.cpp b/src/connectiontcpserver.cpp
index 68c8f7b..236ce8e 100644
--- a/src/connectiontcpserver.cpp
+++ b/src/connectiontcpserver.cpp
@@ -10,7 +10,17 @@
   This software is distributed without any warranty.
 */
 
+#if defined HAVE_STRING_H
+#include <string.h>
+#endif
+ 
+#if defined HAVE_WCHAR_H
+#include <wchar.h>
+#endif
 
+#if __GNUC__ > 3
+#include <cstring>
+#endif
 
 #include "gloox.h"
 
diff --git a/src/dns.cpp b/src/dns.cpp
index fd72c57..e03d99a 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -10,6 +10,17 @@
   This software is distributed without any warranty.
 */
 
+#if defined HAVE_STRING_H
+#include <string.h>
+#endif
+ 
+#if defined HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+
+#if __GNUC__ > 3
+#include <cstring>
+#endif
 
 #include "config.h"
 
