#39757: Compilation with GNU-C++ creates multiple definitions of vsnprintf() Open Date: 2019-11-13 14:00 Last Update: 2019-11-13 14:00 URL for this Ticket: https://osdn.net//projects/mingw/ticket/39757 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=39757 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2019-11-13 14:00 Updated by: keith * New Ticket "Compilation with GNU-C++ creates multiple definitions of vsnprintf ()" created --------------------------------------------------------------------- Ticket Status: Reporter: keith Owner: (None) Type: Issues Status: Open Priority: 5 - Medium MileStone: (None) Component: WSL Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: As reported in this pair of e-mail threads: • https://osdn.net/projects/mingw/lists/archive/users/2019-August/000333.html • https://osdn.net/projects/mingw/lists/archive/users/2019-August/000335.html compilation of any C++ translation unit which refers, either directly or indirectly, to vsnprintf(), will result in link failure, due to multiple public definitions of this symbol. The issue is clearly illustrated by the following code, (abstracted from the latter e-mail report): 1. #include <stdio.h> 2. #include <stdarg.h> 3. 4. void debug_log(const char *fmt, ...) { 5. va_list args; 6. va_start(args, fmt); 7. char buf[1+vsnprintf(NULL, 0, fmt, args)]; 8. vsnprintf(buf, sizeof buf, fmt, args); 9. va_end(args); 10. } 11. 12. main() { 13. printf("mingw-link\n"); 14. } compilation of which yields: $ g++ -o mingw-link.exe main.cpp c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../libmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of `vsnprintf'; main.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here collect2.exe: error: ld returned 1 exit status -- Ticket information of MinGW - Minimalist GNU for Windows project MinGW - Minimalist GNU for Windows Project is hosted on OSDN Project URL: https://osdn.net/projects/mingw/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/mingw/ticket/39757 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=3917&tid=39757