0

I am trying to build all the examples in the Crow library with clang 3.6 and I can see the CC/CXX has been found properly by using clang 3.6. It uses cmake which I am not quite familiar with.

However it failed to find C++11 headers.

Error is like:

'future' file not found

It seems that the libstdc++ is not specified properly, or some people reckon it needs to build the clang libstdc++ myself.

Anyone can shed some light on this will be much appreciated.

rzhomx
  • 85
  • 1
  • 12
  • 2
    Make sure you use C++ 11 features with Clang: http://stackoverflow.com/questions/10408849/how-can-i-use-c-11-features-in-clang – Ciprian Khlud Sep 26 '14 at 06:45
  • Clang should offer ABI compatibility with libstdc++ already, so you shouldn't need to build a special version for clang. You might need to link to a specific abi support library (libsupc++ vs. libc++abi), or you may need update libstdc++ to a version that supports C++11, or use libc++ with -stdlib=libc++. – bames53 Sep 26 '14 at 07:06
  • @CiprianKhlud, actually I did turn it on in cmake: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -stdlib=libstdc++") – rzhomx Sep 26 '14 at 11:50

1 Answers1

0

So based on the previous comment the issue is that you don't enable the C++ 11 mode in Clang.

As in referenced question, the issue is simply that you do not say to Clang (or in future for GCC) to look for C++ headers.

"Clang's command line is gcc-compatible so you have to enable C++11 support via the followinf command-line switch"

-std=c++11

If after this you all you have to do is to write your C++ 11 code. If you use Makefiles you should add to your CXX arguments the command line switch to Clang.

Community
  • 1
  • 1
Ciprian Khlud
  • 434
  • 3
  • 6
  • I actually did turn it on as following: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -stdlib=libstdc++") My concern is that clang tries to use system default c++ headers/libraries which is not the gcc 4.8 I installed. some people saying that I need to rebuild clang with --with-gcc-toolchain to tell where to find my gcc 4.8. but I am trying to avoid rebuilding clang though. – rzhomx Sep 26 '14 at 11:51
  • Did you try to compile the file in isolation? And use the clang++ (or g++ if you want) just to see if it finds this header? (I would expect to find it) – Ciprian Khlud Sep 26 '14 at 13:58
  • it failed to find unordered_map file when I build in this way: /usr/local/bin/clang++ -Wall -std=c++11 -stdlib=libstdc++ excample.cpp – rzhomx Sep 30 '14 at 02:51
  • 1
    So to follow some instructions from googling, I tried to build Clang's libc++abi and libc++ projects, but I ended up with an error: cc : error: unrecognized command line option '-stdlib=libc++' – rzhomx Sep 30 '14 at 02:54