fatal error: 'ext/hash_map.h' file not found on Mac

fatal error: 'ext/hash_map.h' file not found on Mac

我 运行 使用 hash_map.h 下载了一些代码。但是当我使用 g++ 编译它时,它给出了错误信息:

致命错误:'hash_map.h' 找不到文件

我在 google 上搜索,有人建议用 'ext/hash_map.h' 替换 'hash_map.h' 并添加 'using namespace __gnu_cxx;'。但我仍然收到错误消息“致命错误:'ext/hash_map.h' 找不到文件”。

我在 Mac 的终端输入 "sudo find / -name hash_map.h",得到以下结果。

/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/c++/4.2.1/debug/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/backward/hash_map.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/debug/hash_map.h

如何linkhash_map.h下载代码?

我将 hash_map.h 的路径添加到 Makefile 中,如下所示。

g++ -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1/ -c target.cpp

然后我用 'debug/hash_map.h' 替换 'hash_map.h',并添加 'using namespace __gnu_cxx;'。

对我有用。