Clang doesn't see basic headers

sweet_sugar picture sweet_sugar · Oct 13, 2014 · Viewed 80.2k times · Source

I've tried to compile simple hello world on Fedora 20 with Clang, and I get the following output:

d.cpp:1:10: fatal error: 'iostream' file not found

#include <iostream>

I don't have any idea how to resolve it.

Answer

ArunasR picture ArunasR · Oct 14, 2014

This is because g++ is not installed, so libstdc++ is not present.

You can install g++, or if LLVM is preferred, install LLVM libc++ and specify that you want to use it, like so:

sudo apt-get install libc++-dev
clang++ -stdlib=libc++ <rest of arguments>

You may wish to link /usr/bin/c++ to the default compiler:

ln -s /usr/bin/c++ /usr/bin/clang++-libc++

and then compile simply using

$ c++ <args_as_usual>