[Mingw-users] multiple definition of `vsnprintf'

Back to archive index
Matt Brown matt_d_br****@hotma*****
Mon Aug 5 18:41:57 JST 2019


I've just used mingw-get to upgrade my mingw installation.  I believe I've upgraded from "g++ (MinGW.org GCC-8.2.0-3) 8.2.0" to "g++ (MinGW.org GCC-8.2.0-4) 8.2.0".

This upgrade has appeared to cause the link to start failing because of a multiple definition of 'vnsprintf'.

I reproduced the problem with the follow code snippet:

    #include <stdio.h>
    #include <stdarg.h>

    void debug_log(const char *fmt, ...) {
        va_list args1;
        va_start(args1, fmt);
        va_list args2;
        va_copy(args2, args1);
        char buf[1+vsnprintf(NULL, 0, fmt, args1)];
        vsnprintf(buf, sizeof buf, fmt, args2);

    main() {

Here's the output:
    C:\...\mingw-link>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'; C:\...\AppData\Local\Temp\cckc8wEp.o:main.cpp:(.text$vsnprintf[_vsnprintf]+0x0): first defined here
    collect2.exe: error: ld returned 1 exit status

I attempted to return the previous version of mingw with:
    mingw-get upgrade gcc=8.2.0-3

While mingw-get did do something it didn't fix the problem.

I believe the same thing happens with a fresh installation on a PC that hasn't mingw before.

I also pasted the code snippet into www.onlinegdb.com and it seemed happy with it.

Any thoughts greatly appreciated,

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