[cfe-dev] New C++0x feature support in Clang

Larry Evans cppljevans at suddenlink.net
Sun Jan 30 05:01:11 PST 2011

On 01/30/11 06:23, Larry Evans wrote:
> On 01/30/11 05:25, Christopher Jefferson wrote:
>> On 29 Jan 2011, at 19:13, Larry Evans wrote:
>>> On 01/29/11 05:16, Larry Evans wrote:
>>>> On 01/26/11 15:45, Douglas Gregor wrote:
>>>>> Clang has recently gotten much-improved support for the upcoming
>>>>> C++0x standard.
> [snip]
>>> Just #including iostream causes problems, as shown by
>>> compile of the following test.cpp:
>>>  #include <iostream>
>>>  int main(void)
>>>  {
>>>    std::cout<<"Hello World!\n";
>>>    return 0;
>>>  }
>> The problem you are seeing is that adding -std=c++0x adds a bunch of new g++-specific 
>> extensions to libstdc++ (the g++ standard library implementation). To make clang work 
>> on linux these all need supporting (or libc++ needs porting over).
>> Chris
> Thanks Chris,
> Using the compile option, -U__GXX_EXPERIMENTAL_CXX0X__, seems to
> workaround the compile problem.  However, I've not tried linking yet.
> Larry
Linking fails with:

/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -v test.o
-o test.x
clang version 2.9 (trunk 124525)
Target: x86_64-unknown-linux-gnu
Thread model: posix
 "/usr/bin/ld" -z relro --hash-style=both --build-id --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test.x
-L/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../..
-L/usr/lib/x86_64-linux-gnu test.o -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
test.o: In function `__cxx_global_var_init':
test.cpp:(.text+0xc): undefined reference to `std::ios_base::Init::~Init()'
test.cpp:(.text+0x30): undefined reference to `std::ios_base::Init::Init()'
test.o: In function `main':
test.cpp:(.text+0x69): undefined reference to `std::cout'
test.cpp:(.text+0x81): undefined reference to
`std::ostream::operator<<(unsigned int)'
test.cpp:(.text+0x8d): 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*)'
clang: error: linker command failed with exit code 1 (use -v to see
make: *** [test] Error 1

Compilation exited abnormally with code 2 at Sun Jan 30 06:26:12

Presumable there's some link option I could pass to tell clang
where to find main?


More information about the cfe-dev mailing list