[vlc-devel] [RFC] fix multiple definition of `inet_pton' when including microdns.h on WIN32
Steve Lhomme
robux4 at ycbcr.xyz
Fri Jul 19 12:12:45 CEST 2019
On 2019-07-19 12:07, Roland Bewick wrote:
> Hi Steve, thanks for your reply.
>
> On 19/07/2019 2:53 PM, Steve Lhomme wrote:
>> Hi,
>>
>> On 2019-07-19 6:04, Roland Bewick wrote:
>>>
>>> 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)
>>
>> On my win32 cross compilation (clang + mingw32) HAVE_INET_NTOP is set
>> to 1 so this code is never compiled.
>>
>>> 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
>>
>> When building VLC with the same configuration HAVE_INET_PTON is set
>> and thus the compat function is never built either. The ws2_32 one is
>> used.
>>
>> So it seems rather an issue in your toolchain/build script. Are you
>> using MSVC ? The 3.0 branch ?
>
>
> I followed this docker guide:
>
> https://gitlab.com/garfvl/daalenv/blob/master/doc/vlc.md for win64 with
> prebuilt contribs (tip #2 in the readme).
>
> I’m not using MSVC.
>
> I’m on the master branch.
>
> Since I'm using the prebuilt libs and standard? build script for win64,
> I'm worried other people might encounter this as well.
Maybe the docker uses an outdated version on mingw32 ? It seems very odd
that `inet_pton` is defined in ws2_32 but not found in the headers.
Can you check your config.log to see what it says when checking for it ?
>>
>>> 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
>>>
>>>
>>>
>>> _______________________________________________
>>> vlc-devel mailing list
>>> To unsubscribe or modify your subscription options:
>>> https://mailman.videolan.org/listinfo/vlc-devel
>>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list