致命错误:在Mac上找不到'ext/hash_map.h'文件

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

本文关键字:hash map 文件 ext 找不到 致命错误 Mac      更新时间:2023-10-16

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

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

我在谷歌上搜索,有人建议将"hash_map.h"替换为"ext/hash_map.h"并添加"使用命名空间__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

如何将hash_map.h链接到下载的代码?

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

g++ -

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

我将"hash_map.h"替换为"debug/hash_map.h",并添加"使用命名空间__gnu_cxx;"。

它对我有用。