我刚开始使用MinGW来在Windows上编译代码。当尝试使用以下命令创建可执行文件时:
g++ a.cpp -o a.exe -std=c++14
针对下面的代码:
#include <string>
using namespace std;
int main()
{
string x = to_string(123);
return 0;
}
我遇到了以下错误:
C:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of vsnprintf
C:\Users\..\Local\Temp\cc4sJDvK.o:c:/mingw/include/stdio.h:426: first defined here
collect2.exe: error: ld returned 1 exit status
这个错误的根本原因是什么,我该如何解决?虽然我可以很容易地找到替代 to_string()
函数的方法,但我不确定是什么导致了这个错误的发生。