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

时间:2016-02-26 05:14:03

标签: c++ macos stl g++

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

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

我在google上搜索,有人建议更换' hash_map.h' by' ext / hash_map.h'并使用命名空间__gnu_cxx添加''。但我仍然收到错误消息'致命错误:' ext / hash_map.h'文件未找到'。

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

/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链接到下载的代码?

1 个答案:

答案 0 :(得分:0)

我将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

我替换了' hash_map.h'通过' debug / hash_map.h',并添加'使用命名空间__gnu_cxx;'。

它对我有用。