Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What could cause clang to not find the unordered_map header?

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
like image 351
Niklas R Avatar asked Oct 07 '14 09:10

Niklas R


1 Answers

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.

like image 92
over_optimistic Avatar answered Oct 22 '22 10:10

over_optimistic