mingw compatibility - IPV6_V6ONL undefined and other symbols #5

Closed
davidm opened this Issue May 2, 2012 · 2 comments

Comments

Projects
None yet
3 participants
Contributor

davidm commented May 2, 2012

In the latest "unstable" branch, IPV6_V6ONL is not always defined (e.g. when I cross compiled mingw from Linux). A workaround is seen in:

http://svn.apache.org/repos/asf/apr/apr/trunk/network_io/win32/sockopt.c

So, I did

diff --git a/src/options.c b/src/options.c
index 6cae7ee..2844c0c 100644
--- a/src/options.c
+++ b/src/options.c
@@ -10,6 +10,11 @@
 #include "options.h"
 #include "inet.h"

+/* not available on older Windows SDK and mingw */
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
+
 /*=========================================================================*\
 * Internal functions prototypes
 \*=========================================================================*/
diff --git a/src/tcp.c b/src/tcp.c
index 94148c5..fdd85f4 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -13,6 +13,11 @@
 #include "options.h"
 #include "tcp.h"

+/* not available on older Windows SDK and mingw */
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
+
 /*=========================================================================*\
 * Internal function prototypes
 \*=========================================================================*/
diff --git a/src/udp.c b/src/udp.c
index 0241cc5..6630744 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -13,6 +13,11 @@
 #include "options.h"
 #include "udp.h"

+/* not available on older Windows SDK and mingw */
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
+
 /* min and max macros */
 #ifndef MIN
 #define MIN(x, y) ((x) < (y) ? x : y)

However, inet.c and tcp.c still rely on some *nix specific functions:

CMakeFiles/socket_core.dir/objects.a(inet.c.obj):inet.c:(.text+0x2c5): undefined reference to `_socket_gaistrerror'
CMakeFiles/socket_core.dir/objects.a(inet.c.obj):inet.c:(.text+0x5ad): undefined reference to `_inet_ntop'
CMakeFiles/socket_core.dir/objects.a(inet.c.obj):inet.c:(.text+0x690): undefined reference to `_inet_ntop'
CMakeFiles/socket_core.dir/objects.a(inet.c.obj):inet.c:(.text+0x7b4): undefined reference to `_inet_ntop'
CMakeFiles/socket_core.dir/objects.a(inet.c.obj):inet.c:(.text+0x897): undefined reference to `_inet_ntop'
CMakeFiles/socket_core.dir/objects.a(inet.c.obj):inet.c:(.text+0xb5b): undefined reference to `_socket_gaistrerror'
CMakeFiles/socket_core.dir/objects.a(inet.c.obj):inet.c:(.text+0xc79): undefined reference to `_socket_gaistrerror'
CMakeFiles/socket_core.dir/objects.a(tcp.c.obj):tcp.c:(.text+0xb62): undefined reference to `_socket_gaistrerror'
Contributor

darkrain42 commented May 22, 2012

I was looking at this briefly a few weeks back (building with Visual Studio, which I quickly abandoned) -- wsocket.c needs to define socket_gaistrerror as a thin wrapper around wstrerror. See MSDN docs on getaddrinfo's return value

Contributor

darkrain42 commented May 22, 2012

And for inet_ntop (apparently only available in Windows Vista and Windows Server 2008 and newer), the Win32 API offers WSAAddressToString.

@diegonehab diegonehab closed this May 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment