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

Steve Lhomme robux4 at ycbcr.xyz
Mon Jul 22 07:17:04 CEST 2019


On 2019-07-20 4:53, Roland Bewick wrote:
> 
> On 19/07/2019 5:50 PM, Steve Lhomme wrote:
>> On 2019-07-19 12:37, Roland Bewick wrote:
>>>
>>> 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
>>
>> Yes, there are many different checks but in the end it is found.
>> You can see HAVE_INET_PTON is set to 1 afterwards up to the end of the 
>> script. So it should be set to that value in config.h as well.
> 
> Yes, it's set to 1.
> 
> But libmicrodns wasn't built by my system because I'm using the prebuilt 
> contribs. So does that mean in the nightly build HAVE_INET_PTON was set 
> to 0?

Possibly yes. It's not recommended to use prebuilt contribs in general 
in case you know you have the same toolchain as the build bot. I would 
assume it is the case with the docker but it seems wrong. So you should 
build the contribs locally. It will take longer but at least it's 
guaranteed to work.


More information about the vlc-devel mailing list