天天看點

Clang Bug 43375 Mingw-w64 runtime failure: Unknown pseudo relocation protocol version 16777216解決方法

Clang Bug 43375(未修複) 解決方法

在C++中使用STL中的map并target MinGW-w64時,Clang會導緻如下編譯錯誤。

Mingw-w64 runtime failure:

Unknown pseudo relocation protocol version 16777216.

代碼如下:

#include <iostream>
#include <map>

using namespace std;

int main()
{
	map<int,string> m;//map<int,string> m={{1,"Bug"}};
	m[1]="Damn";//試圖用[]操作符給map添加或改變value
	for (auto it : m)
	{
		cout << it.first << ends << it.second << endl;
	}
	system("pause");
	return 0;
}
           

MinGW-w64 & GCC版本:8.1.0 LLVM/Clang版本:11.0.0

Github上的解決方法:編譯指令中删除 –target=x86_64-w64-mingw

https://github.com/microsoft/vscode-cpptools/issues/3373

但同時編譯會報錯:找不到頭檔案

經實驗,将 -std=c++17 或 -std=c++20 改為 -std=c++11 或 -std=c++14 即可成功編譯。

更新:将GCC或MinGW-w64更新更高版本可解決問題。

GCC & MinGW-w64最新版下載下傳位址:WinLibs standalone build of GCC and MinGW-w64 for Windows

該Bug頁面:https://bugs.llvm.org/show_bug.cgi?id=43375

Clang Bug 43375 Mingw-w64 runtime failure: Unknown pseudo relocation protocol version 16777216解決方法
Clang Bug 43375 Mingw-w64 runtime failure: Unknown pseudo relocation protocol version 16777216解決方法
Clang Bug 43375 Mingw-w64 runtime failure: Unknown pseudo relocation protocol version 16777216解決方法