6

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
Niklas R
  • 16,299
  • 28
  • 108
  • 203
  • 1
    If you compile your simple test program with `clang++ (those options) test.cpp`, it'll fail too. At that point, you can simply start removing options to see which is the one that causes the problem. (Start from the front. It's one of the first.) –  Oct 07 '14 at 09:42
  • Strange that `clang++ test.cpp` compiles, as `` requires C++11 (`-std=c++11`)... – Jarod42 Oct 07 '14 at 09:45
  • What is the version of your libstdc++? Did you compile `test.cpp` with libstdc++ as well? – eerorika Oct 07 '14 at 09:49
  • @Jarod42 Just tried it again, it compiles without any problems. – Niklas R Oct 07 '14 at 09:56
  • @hvd Thanks, I followed your advice and it seems to be `-stdlib=libstdc++` – Niklas R Oct 07 '14 at 09:57
  • @user2079303 That is the root of the problem indeed! How can I check the version of `libstdc++`? – Niklas R Oct 07 '14 at 09:57
  • @NiklasR check this answer for that: http://stackoverflow.com/a/10355215/2079303 – eerorika Oct 07 '14 at 10:17

2 Answers2

6

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.

over_optimistic
  • 1,399
  • 2
  • 18
  • 27
-2

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

Adrian May
  • 2,127
  • 15
  • 24