From 60334ce1f1db47b849d2b26986522dc0453e4a6d Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 17 Apr 2021 05:28:40 +0300
Subject: [PATCH] SDL2 targets WinXP and newer: always use winsock2 with
windows builds.
Closes: https://github.com/libsdl-org/SDL_net/issues/26
---
SDLnetsys.h | 7 -------
VisualC/SDL_net.vcxproj | 4 ++--
VisualC/SDL_net_VS2008.vcproj | 4 ++--
configure | 7 ++-----
configure.ac | 7 ++-----
5 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/SDLnetsys.h b/SDLnetsys.h
index 6de23a8..68da3db 100644
--- a/SDLnetsys.h
+++ b/SDLnetsys.h
@@ -37,15 +37,8 @@
/* Include system network headers */
#if defined(__WIN32__) || defined(WIN32)
#define __USE_W32_SOCKETS
-#ifdef _WIN64
#include <winsock2.h>
#include <ws2tcpip.h>
-#else
-#include <winsock.h>
-/* NOTE: windows socklen_t is signed
- * and is defined only for winsock2. */
-typedef int socklen_t;
-#endif /* W64 */
#include <iphlpapi.h>
#else /* UNIX */
#ifdef __OS2__
diff --git a/VisualC/SDL_net.vcxproj b/VisualC/SDL_net.vcxproj
index 1efe9cf..665c23f 100644
--- a/VisualC/SDL_net.vcxproj
+++ b/VisualC/SDL_net.vcxproj
@@ -101,7 +101,7 @@
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
- <AdditionalDependencies>wsock32.lib;iphlpapi.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;iphlpapi.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
@@ -153,7 +153,7 @@
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
- <AdditionalDependencies>wsock32.lib;iphlpapi.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;iphlpapi.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
</Link>
<Bscmake />
diff --git a/VisualC/SDL_net_VS2008.vcproj b/VisualC/SDL_net_VS2008.vcproj
index 16f5b38..aca38df 100644
--- a/VisualC/SDL_net_VS2008.vcproj
+++ b/VisualC/SDL_net_VS2008.vcproj
@@ -69,7 +69,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="wsock32.lib iphlpapi.lib SDL2.lib"
+ AdditionalDependencies="ws2_32.lib iphlpapi.lib SDL2.lib"
GenerateDebugInformation="true"
SubSystem="2"
/>
@@ -221,7 +221,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="wsock32.lib iphlpapi.lib SDL2.lib"
+ AdditionalDependencies="ws2_32.lib iphlpapi.lib SDL2.lib"
SubSystem="2"
/>
<Tool
diff --git a/configure b/configure
index f521b7e..9ec6045 100755
--- a/configure
+++ b/configure
@@ -1575,7 +1575,7 @@ Optional Features:
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--disable-sdltest Do not try to compile and run a test SDL program
- --enable-gui Try to build the GUI test programs default=yes
+ --enable-gui Try to build the GUI test programs [default=yes]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -15476,11 +15476,8 @@ fi
case "$host" in
- x86_64-*-mingw*)
- INETLIB="-lws2_32 -liphlpapi"
- ;;
*-*-cygwin* | *-*-mingw*)
- INETLIB="-lwsock32 -liphlpapi"
+ INETLIB="-lws2_32 -liphlpapi"
;;
sparc*-*-solaris*)
INETLIB="-lsocket -lnsl"
diff --git a/configure.ac b/configure.ac
index f1bae47..130f07f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,11 +81,8 @@ AM_CONDITIONAL(USE_VERSION_RC, test x$use_version_rc = xtrue)
dnl Figure out which networking libraries to use
case "$host" in
- x86_64-*-mingw*)
- INETLIB="-lws2_32 -liphlpapi"
- ;;
*-*-cygwin* | *-*-mingw*)
- INETLIB="-lwsock32 -liphlpapi"
+ INETLIB="-lws2_32 -liphlpapi"
;;
sparc*-*-solaris*)
INETLIB="-lsocket -lnsl"
@@ -118,7 +115,7 @@ LIBS="$LIBS $SDL_LIBS"
dnl Check for GUI library for the chat client
have_GUI=no
AC_ARG_ENABLE(gui,
-[ --enable-gui Try to build the GUI test programs [default=yes]],
+[AS_HELP_STRING([--enable-gui],[Try to build the GUI test programs [default=yes]])],
, enable_gui=yes)
if test x$enable_gui = xyes; then
AC_LANG_PUSH(C++)