MinGW g++: Multiple definition of vsnprintf when using to_string

前端 未结 4 1980
Happy的楠姐
Happy的楠姐 2020-12-08 17:40

I just started using MinGW for Windows. When trying to create executable using

g++ a.cpp -o a.exe -std=c++14

for the code below:



        
相关标签:
4条回答
  • 2020-12-08 17:45

    Installing MinGW packages mingw32-libmingwex-* will link an appropriate version of vsnprintf and avoid the linker error.

    0 讨论(0)
  • 2020-12-08 17:49

    This issue, i.e. multiple definition of vsnprintf, still exists in MinGW as December 2019.

    After investigating a lot, I found the solution in the official mailing list.

    It's a bug in mingwrt-5.2.2. Downgrading to the mingwrt-5.2.1 version solves that issue. To do that, just input the following command:

    mingw-get upgrade mingwrt=5.2.1
    

    Then restart the MinGW shell.

    Read the full story here.

    Note: MinGW-w64 and MinGW are separate projects, so the accepted solution is not so helpful to me, as I want to keep MinGW and not to move to MinGW-w64.

    0 讨论(0)
  • There are multiple definitions of vsnprintf in both stdio.h and libmingwex.a. I am able to work this around by adding #define __USE_MINGW_ANSI_STDIO 0 to the start of the code, before any includes, which disables the definition of vsnprintf in stdio.h.

    0 讨论(0)
  • 2020-12-08 18:03

    I solved this issue using MinGW w64 compiler

    1. download mingw-w64-install.exe
    2. setup to Version: 6.3.0, Architecture: i686, Threads: posix, Exception: dwarf and Build revision: 2.

    I hope this will be of some help.

    0 讨论(0)
提交回复
热议问题