[vlc-devel] [RFC] fix multiple definition of `inet_pton' when including microdns.h on WIN32

Roland Bewick roland.bewick at gmail.com
Fri Jul 19 06:04:02 CEST 2019


Hi, I'm looking to use the inet_pton function within 
modules\services_discovery\microdns.c

Unfortunately it looks to be defined twice when I cross compile for Windows:

1. in libmicrodns (compat/inet.c) - will only be declared if defined 
(_WIN32) && !defined(HAVE_INET_NTOP)
2. in libws2_32.a (I think from including winsock2.h?)

/opt/gcc-x86_64-w64-mingw32/x86_64-w64-mingw32/lib/libws2_32.a(dywbs00169.o):(.text+0x0): 
multiple definition of `inet_pton'
/win64/vlc/contrib/x86_64-w64-mingw32/lib/libmicrodns.a(inet.o):/win64/libmicrodns/build/../compat/inet.c:60: 
first defined here

I've commented out the contents of the compat/inet.c file and 
successfully VLC with the modified libmicrodns.

Is it ok to add a patch to contrib\src\microdns (see example below), or 
is there a better way? Is it because it's linking libmicrodns 
before//libws2_32 rather than after?

Thanks,

Roland


 From e364a3201b30e88236dd62c892e9cb24e9c36fb2 Mon Sep 17 00:00:00 2001
From: Roland Bewick <roland.bewick at gmail.com>
Date: Thu, 18 Jul 2019 11:55:59 +0700
Subject: [PATCH] remove unneeded inet compatibility

---
  compat/inet.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compat/inet.c b/compat/inet.c
index 2983e4d..9c2dfb8 100644
--- a/compat/inet.c
+++ b/compat/inet.c
@@ -27,7 +27,7 @@
  #include "compat.h"
  #include "utils.h"

-#if defined (_WIN32) && !defined(HAVE_INET_NTOP)
+/*#if defined (_WIN32) && !defined(HAVE_INET_NTOP)
  const char *
  inet_ntop(int af, const void *src, char *dst, socklen_t size)
  {
@@ -67,4 +67,4 @@ int inet_pton (int af, const char *src, void *dst)
      errno = EAFNOSUPPORT;
      return -1;
  }
-#endif // _WIN32 && !inet_ntop
+#endif // _WIN32 && !inet_ntop */
-- 
2.17.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190719/c6331e57/attachment.html>


More information about the vlc-devel mailing list