What could cause clang to not find the unordered_map header?

霸气de小男生 提交于 2019-12-19 02:58:10

问题


I'm trying to compile a program I found on the web using Clang++. The Makefile generates this command:

clang++ -c -arch x86_64 -msse3 -std=c++11 -stdlib=libstdc++
-Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type
-Wno-non-virtual-dtor -Wno-exit-time-destructors -Wformat -Wmissing-braces
-Wparentheses -Wno-switch -Wunused-function -Wunused-label -Wno-unused-parameter
-Wunused-variable -Wunused-value -Wno-empty-body -Wuninitialized -Wunknown-pragmas
-Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion
-Wint-conversion -Wno-shorten-64-to-32 -Wenum-conversion -Wno-newline-eof
-Wno-c++11-extensions -Wno-logical-op-parentheses -Wno-trigraphs
-Wno-invalid-offsetof -Wno-sign-conversion -Wdeprecated-declarations
-fmessage-length=0 -fno-exceptions -fstrict-aliasing -fvisibility=hidden
-fvisibility-inlines-hidden -funsafe-math-optimizations -ftrapping-math -fno-rtti
-fpascal-strings -fasm-blocks -O3 -Iinclude/ src/main.cpp

But I get

src/main.cpp:23:10: fatal error: 'unordered_map' file not found
#include <unordered_map>
         ^
1 error generated.

If I compile a simple program that includes <unordered_map> running clang++ test.cpp, it compiles fine.

I'm on

Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix

回答1:


I had the same issue when compiling glogg.

As the comments have pointed out. it was stdlib.

In the makefile after running qmake. Change this line from

CXXFLAGS      = -g -Wextra -std=c++11 -DGLOGG_VERSION=\"`cat .tarball-version`\" -O2 -arch x86_64 -Wall -W $(DEFINES)

To this line below

CXXFLAGS      = -g -Wextra -std=c++11 -stdlib=libc++ -DGLOGG_VERSION=\"`cat .tarball-version`\" -O2 -arch x86_64 -Wall -W $(DEFINES)

notice "-stdlib=libc++" was specified in the cxxflags. It's autospecified in the linker flags, I guess it also needs to be specified in for the C++ flags.




回答2:


It says -Wno-c++11-extensions. What wrote that makefile?



来源:https://stackoverflow.com/questions/26233011/what-could-cause-clang-to-not-find-the-unordered-map-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!