[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 12:37:41 CEST 2019


On 19/07/2019 5:12 PM, Steve Lhomme wrote:
> 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 ?

It looks like it's failing so HAVE_INET_PTON is not being set as expected.

 From line 13814:

configure:25828: checking for library containing inet_pton
configure:25859: x86_64-w64-mingw32-gcc -o conftest.exe -g -O2 
-I/win64/vlc/contrib/x86_64-w64-mingw32/include -mms-bitfields 
-I/win64/vlc/contrib/x86_64-w64-mingw32/include 
-D__USE_MINGW_ANSI_STDIO=1  -Wl,--nxcompat -Wl,--no-seh 
-Wl,--dynamicbase -Wl,--high-entropy-va -Wl,--image-base,0x140000000 
-L/win64/vlc/contrib/x86_64-w64-mingw32/lib conftest.c  >&5
/tmp/ccT0CMSB.o: In function `main':
/win64/vlc/win64/conftest.c:89: undefined reference to `inet_pton'
/win64/vlc/win64/conftest.c:89:(.text.startup+0xa): relocation truncated 
to fit: R_X86_64_PC32 against undefined symbol `inet_pton'
collect2: error: ld returned 1 exit status
configure:25859: $? = 1
configure: failed program was:

...

If needed, you can see the full config file below (1MB)

https://www.dropbox.com/s/m2rklvzyl1lkst6/config.log?dl=0


>
>>>
>>>> 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
> _______________________________________________
> 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