Why doesn't Clang come with standard library headers?

Therhang picture Therhang · Jul 22, 2015 · Viewed 9.2k times · Source

I downloaded Clang 3.6.2 from this website and am trying to set it up with Code::Blocks under Windows. Unfortunately, it fails to compile a simple "hello world" program on the grounds that it doesn't know where iostream is.

Looking through the install folder, it does not appear to include a standard library with it. Why? And how do I get it?

Answer

Mats Petersson picture Mats Petersson · Jul 22, 2015

The standard library is NOT part of the compiler itself. It is part of the runtime environment on a particular platform. Sure, some organisations put together a "kit" with all the necessary parts to build an application - there may even be someone that packages a Clang compiler with a suitable runtime.

In general, you should be able to download the Windows SDK and get the relevant header files there - and if you use clang-cl, it should be largely compatible with the MSVC compiler [or provide clang or clang++ with the correct -fms-compatibility or whatever it is called].

Or as suggested in the other answer, use libcxx, but it's not 100% complete for Windows.