diff --git a/CMakeLists.txt b/CMakeLists.txt index 334b5c3865..5f51997f2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1785,7 +1785,8 @@ check_function_exists("setlocale" HAVE_SETLOCALE) check_function_exists("setrlimit" HAVE_SETRLIMIT) if(WIN32) - check_symbol_exists("if_nametoindex" "winsock2.h;iphlpapi.h" HAVE_IF_NAMETOINDEX) # Windows Vista+ non-UWP + # include wincrypt.h as a workaround for mingw-w64 __MINGW64_VERSION_MAJOR <= 5 header bug */ + check_symbol_exists("if_nametoindex" "winsock2.h;wincrypt.h;iphlpapi.h" HAVE_IF_NAMETOINDEX) # Windows Vista+ non-UWP */ else() check_function_exists("if_nametoindex" HAVE_IF_NAMETOINDEX) # net/if.h check_function_exists("realpath" HAVE_REALPATH) diff --git a/configure.ac b/configure.ac index acf253eadc..27c46bbffc 100644 --- a/configure.ac +++ b/configure.ac @@ -4275,6 +4275,7 @@ if test "$curl_cv_native_windows" = 'yes'; then #define WIN32_LEAN_AND_MEAN #endif #include + #include /* workaround for mingw-w64 __MINGW64_VERSION_MAJOR <= 5 header bug */ #include ]],[[ if_nametoindex(""); diff --git a/lib/url.c b/lib/url.c index 3d78ceeed5..df2a332061 100644 --- a/lib/url.c +++ b/lib/url.c @@ -60,6 +60,9 @@ #endif #if defined(HAVE_IF_NAMETOINDEX) && defined(_WIN32) +#if defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR <= 5) +#include /* workaround for old mingw-w64 missing to include it */ +#endif #include #endif