diff --git a/tools/dhtchat.cpp b/tools/dhtchat.cpp
index baed3b6102f92f683577ab851a4b9d856fbf4c9a..3273be7a8a52fe7fcf679f348f97d1cc447a30fb 100644
--- a/tools/dhtchat.cpp
+++ b/tools/dhtchat.cpp
@@ -16,6 +16,9 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "tools_common.h"
 #include <opendht/rng.h>
diff --git a/tools/dhtscanner.cpp b/tools/dhtscanner.cpp
index 44dd39afce1e21998722ef56fa49ac7b4e73d4a0..00884fd4f748d0b1a20125d6eacce5a81e20a7ce 100644
--- a/tools/dhtscanner.cpp
+++ b/tools/dhtscanner.cpp
@@ -16,6 +16,9 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "tools_common.h"
 #include <opendht/node.h>
diff --git a/tools/tools_common.h b/tools/tools_common.h
index ff6999a34dc33a205650872c6cecd338d02bf78b..0ce5ca5201209106cd5c1a99548d22aa26d1bdb8 100644
--- a/tools/tools_common.h
+++ b/tools/tools_common.h
@@ -25,6 +25,10 @@
 #include <opendht/log.h>
 #include <opendht/crypto.h>
 #include <opendht/network_utils.h>
+#ifdef OPENDHT_INDEXATION
+#include <opendht/indexation/pht.h>
+#endif
+
 #ifndef WIN32_NATIVE
 #include <getopt.h>
 #include <readline/readline.h>