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
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> >&, charconst*)'
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