--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -9,7 +9,7 @@
 add_executable(osmpbf-outline osmpbf-outline.cpp)
 
 target_include_directories(osmpbf-outline SYSTEM PRIVATE ${ZLIB_INCLUDE_DIR})
-target_link_libraries(osmpbf-outline PRIVATE osmpbf ZLIB::ZLIB protobuf::libprotobuf)
+target_link_libraries(osmpbf-outline PRIVATE osmpbf ZLIB::ZLIB protobuf::libprotobuf ws2_32)
 set_property(TARGET osmpbf-outline PROPERTY CXX_STANDARD 11)
 
 install(TARGETS osmpbf-outline RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
--- a/tools/osmpbf-outline.cpp
+++ b/tools/osmpbf-outline.cpp
@@ -14,7 +14,7 @@
 #include <zlib.h>
 
 // netinet or winsock2 provides the network-byte-order conversion function
-#ifdef D_HAVE_WINSOCK
+#ifdef _WIN32
     #include <winsock2.h>
 #else
     #include <netinet/in.h>
