Opened 5 years ago

Last modified 5 years ago

#15005 confirmed enhancement

Load getaddrinfo() and freeaddrinfo() dynamically when using non-MSVC compiler with wxUSE_IPV6=1

Reported by: guenter Owned by:
Priority: low Milestone:
Component: network Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no


When I set "#define wxUSE_IPV6 1" in setup.h build with mingw32 stops with error "wspiapi.h not found".
When I replace wspiapi.h by ws2spi.h build goes through.

index ec572a2..e93797f 100644
--- a/src/common/sckaddr.cpp
+++ b/src/common/sckaddr.cpp
@@ -102,7 +102,11 @@ IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)

disable a warning occurring in Microsoft own version of this file
#pragma warning(disable:4706)


  • #include <wspiapi.h>

+ #ifdef MINGW32
+ #include <ws2spi.h>
+ #else
+ #include <wspiapi.h>
+ #endif

#ifdef VISUALC

#pragma warning(default:4706)


Attachments (1)

guenter1.patch download (608 bytes) - added by guenter 5 years ago.

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by guenter


comment:1 Changed 5 years ago by guenter

  • Patch set

comment:2 Changed 5 years ago by vadz

  • Patch unset
  • Priority changed from normal to low
  • Status changed from new to confirmed
  • Summary changed from No file "wspiapi.h" for mingw32 to Load getaddrinfo() and freeaddrinfo() dynamically when using non-MSVC compiler with wxUSE_IPV6=1
  • Type changed from build error to enhancement

The build goes through, perhaps, but with a different semantics: now your program binds to getaddrinfo() which is not always available in XP (AFAIR) and not available at all in the previous versions.

As the comment in the sources say, we really should use wxDynamicLibrary to load this function and freeaddrinfo() ourselves from the DLLs that WspiapiGetAddrInfo() looks in, i.e. ws2_32.dll first and then wship6.dll. Of course, WspiapiGetAddrInfo() also provides its own implementation of these functions which are going to be more difficult to reimplement...

Anyhow, for now I'll just fix compilation for MinGW but, again, this is not ideal.

comment:3 Changed 5 years ago by VZ

(In [73626]) Fix compilation for MinGW with wxUSE_IPV6==1.

MinGW doesn't provide wspiapi.h header, so only include it when using MSVC and
include ws2tcpip.h which directly declares the functions used for the other

This doesn't have quite the same semantics but it's better than failing to
compile at all.

See #15005.

Note: See TracTickets for help on using tickets.