我剛開始使用MinGW for Windows。當嘗試使用MinGW g ++:使用to_string時vsnprintf的多重定義
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()
函數的替代函數,但我不確定是什麼導致此錯誤首先發生。
聽起來像MinGW安裝已損壞。 – SurvivalMachine