[Mingw-users] multiple definitions of 'vsnprintf'

Back to archive index
Keith Marshall keith****@users*****
Sat Aug 3 03:22:47 JST 2019


On 31/07/19 19:36, Laura Yindra wrote:
> I am getting the error:
>  libmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of
> 'vsnprintf'; main.cpp:(.text$vsnprintf[_nsvprintf]+0x0): first defined
> here collect2.exe: error: ld returned 1 exit status

Thank you for bringing this to my attention.  I can confirm that there
is a reproducible problem here; however ...

> the contents of main.cpp are
> #include <string>
> #include <iostream>
> int main(void)
> {
>     std::cout << "Hello World. "<<std::to_string(1)<<std::endl;
>     return 0;
> }
> 
> the command I am executing in msys.bat is
> g++ -std=c++11 main.cpp
> 
> I only get this error when mingw32-gcc-g++ version is 8.2.0-4
> This error is not in mingw32-gcc-g++ version 6.3.0-1 

... the GCC version is not pertinent.  Yes, like you, I see the problem
when compiling your test case with GCC-8.2.0, and (initially) I do not
see it with either GCC-6.3.0 or GCC-7.3.0, but only because the mingwrt
versions associated with each of those earlier GCC versions were 5.1.0,
and 5.1.1 respectively; if I associate mingwrt-5.2.2, (or at least the
updated version of <stdio.h> from mingwrt-5.2.2), with each of those two
earlier GCC installations, I see the same issue propagate to all three!

The actual cause of the issue is that the changes to <stdio.h>, to
resolve https://osdn.net/projects/mingw/ticket/39224, cause g++ to emit
multiple publicly visible instances of vsnprintf(), each of which refers
to an extern implementation of __mingw_vsnprintf(), and conflicts with
its publicly visible vsprintf() alias, within the translation unit in
which __mingw_vsnprintf() itself is implemented.

The attached patch should correct this; please file a formal bug report,
at https://osdn.net/ticket/newticket.php?group_id=3917, against which I
may apply it.

-- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vsnprintf-definition.patch
Type: text/x-patch
Size: 2084 bytes
Desc: not available
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20190802/e15dffcc/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20190802/e15dffcc/attachment.sig>


More information about the MinGW-Users mailing list
Back to archive index