2014-10-07 66 views
5

我想编译一个程序,我使用Clang ++在网上找到。 Makefile的生成此命令:什么可能导致clang找不到unordered_map头?

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 

,但我得到

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

如果我编译一个简单的程序,包括<unordered_map>运行clang++ test.cpp,它编译罚款

我在

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

如果你用'clang ++(这些选项)test.cpp'编译你的简单测试程序,它也会失败。在这一点上,你可以简单地开始删除选项,看看哪个是导致问题的原因。 (从前面开始,这是第一个) – hvd 2014-10-07 09:42:20

+0

奇怪的是'clang ++ test.cpp'编译为''需要C++ 11('-std = C++ 11')... – Jarod42 2014-10-07 09:45:01

+0

什么是你的libstdC++的版本?你是否用libstdC++编译'test.cpp'? – user2079303 2014-10-07 09:49:52

回答

4

编译glogg时遇到同样的问题。

正如评论指出的那样。这是stdlib。

在运行qmake之后的makefile中。从

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

改变这一行向该线以下

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

通知 “-stdlib = libc的++” 在CXXFLAGS指定。它是在链接器标志中自动指定的,我想它也需要在C++标志中指定。

-2

它说-Wno-C++ 11的扩展。什么编写了这个makefile?

+3

'-W'是一个选项,它控制警告。它有什么关系? – Angew 2014-10-07 10:08:31

相关问题