Clang fails to compile c++

Hello Everyone. Recently I decided to give the compiler clang a try after hearing about it.

I installed the entire LLVM toolchain from the official (LLVM) Saucy Repo.
I'm on Xubuntu 13.10


But, clang fails to compile even a simple hello world program!
On command
clang hello.cpp -Wall -Werror -std=c++11 -stdlib=libstdc++
It produces some vague error about a missing file:
1
2
3
4
5
6
In file included from hello.cpp:1:
/usr/lib/gcc/i686-linux-gnu/4.8/../../../../include/c++/4.8/iostream:38:10: fatal error: 
      'bits/c++config.h' file not found
#include <bits/c++config.h>
         ^
1 error generated.

There is no c++config.h file in my computer. I have also got g++ 4.8.1 installed
substituting clang with clang++ makes no difference. Please Help.
Clang version: 3.4
Just by Googling, you may have to set the path to c++config.h yourself.
http://comments.gmane.org/gmane.comp.compilers.clang.devel/17385
http://stackoverflow.com/questions/9201521/g-4-6-issue-no-bits-cconfig-h-file-as-required-by-the-header-cstring

But I don't have access to CLang right now, so I can't be sure. I think I dealt with this on a clang/PPC Mac but I can't remember the details.
I did set it, but it still does not work.
locate c++config.h
leads me here:
/usr/include/i386-linux-gnu/c++/4.8/bits/
But, when I run clang with
clang hello.cpp -Wall -std=c++11 -stdlib=libstdc++ -I/usr/include/i386-linux-gnu/c++/4.8
It fails with the *same* error

EDIT: Error fixed. I don't know why. I rebooted my computer and it started working again. Many thanks for the quick reply.

EDIT2: Fails to link with error
1
2
3
4
5
6
7
8
9
/tmp/hello-pVOk08.o: In function `main':
hello.cpp:(.text+0x8): undefined reference to `std::cout'
hello.cpp:(.text+0x21): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
hello.cpp:(.text+0x27): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
hello.cpp:(.text+0x33): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
/tmp/hello-pVOk08.o: In function `__cxx_global_var_init':
hello.cpp:(.text.startup+0x10): undefined reference to `std::ios_base::Init::Init()'
hello.cpp:(.text.startup+0x16): undefined reference to `std::ios_base::Init::~Init()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)


Compiles fine, mind you.

EDIT3: Managed a workaround:
Compile with clang,
link with g++.
I know, kinda riddiculous, But hey, It does the job.
But, I'm keeping this unsolved until someone can help me out about clang's link failing
Last edited on
Finally solved
clang -stdlib=libc++ -std=c++11 -lc++ <sourcefile> -o[outfile]
Topic archived. No new replies allowed.