Emscripten:致命错误:找不到“tr1/unordered_map”文件

问题描述

所以我正在尝试使用 emscripten 编译以下代码

// this is test.cpp

#include<iostream>
#include<string.h>
#include<fstream>
#include<tr1/unordered_map> //needed to use unordered maps in C++. not needed C++11 onwards
#include "C:\Users\<myusername>\Documents\PROGRAMMING\examplefolder\pugixml-1.11\src\pugixml.hpp"

#include <ctime>
#include <chrono>

int main()
{
    std::cout<<"dis IS DA TEST";
    return 0;
}

我的实际代码要大得多,但我在这里缩短了它以强调我的主要疑问(我已经留下了我正在使用的所有头文件)。此代码使用 g++ 完美编译并提供所有预期输出

但是当我使用 emcc test.cpp -s WASM=1 -o TRY.html 将它编译为 web 程序集时,它给了我这个错误

test.cpp:4:9: Fatal error: 'tr1/unordered_map' file not found
#include<tr1/unordered_map> //needed to use unordered maps in C++. not needed C++11 onwards
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
emcc: error: 'C:/Users/vargh/emsdk/upstream/bin\clang++.exe -DEMSCRIPTEN -fignore-exceptions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -Xclang -iwithsysroot/include/SDL -target wasm32-unkNown-emscripten -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=15 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -flegacy-pass-manager -Werror=implicit-function-declaration --sysroot=C:\Users\vargh\emsdk\upstream\emscripten\cache\sysroot -Xclang -iwithsysroot/include\compat test.cpp -c -o C:\Users\<myusername>\AppData\Local\Temp\emscripten_temp_e9j9ld9x\test_0.o' Failed (1)

为什么emcc找不到这个文件?有没有其他方法可以在 C++ 中处理 unordered_maps?

我正在使用 tr1,因为我在 Stack Overflow 问题中遇到了同样的错误C++ error: 'unordered_map' does not name a type

有人可以帮我吗?

解决方法

为什么emcc找不到这个文件?有没有其他方法可以在 C++ 中处理 unordered_maps?

因为它在 2011 年移至 <unordered_map>

如果这两个地方都没有,那你就是一个很老的叮当声,它没有 unordered_map