diff --git a/c/opendht.cpp b/c/opendht.cpp
index 6aa83d7deff83b6d274400ab3ab31385f3cf2a08..c2b312e6ed327883cc20936c9ed779c18397e2e2 100644
--- a/c/opendht.cpp
+++ b/c/opendht.cpp
@@ -10,6 +10,8 @@ using CertSp = std::shared_ptr<dht::crypto::Certificate>;
 extern "C" {
 #endif
 
+#include <errno.h>
+
 // dht::InfoHash
 
 inline dht_infohash dht_infohash_to_c(const dht::InfoHash& h) {