Clang doesn't see basic headers

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>

Point 3 solved the problem for me.

1. Had the same issue, fedora 21::clang 3.5.0:

clang++ -std=c++14 -pedantic -Wall test_01.cpp -o test_01 -v

2.

ignoring nonexistent directory "/usr/lib/gcc/i686-redhat-linux/4.9.2/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/bin/../lib/clang/3.5.0/include
 /usr/include
End of search list.
test_01.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>

3.

sudo yum install gcc-c++

4.

#include "..." search starts here:
#include <...> search starts here:
 /bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2
 /bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2/i686-redhat-linux
 /bin/../lib/gcc/i686-redhat-linux/4.9.2/../../../../include/c++/4.9.2/backward
 /usr/local/include
 /usr/bin/../lib/clang/3.5.0/include
 /usr/include
 /usr/lib/gcc/i686-redhat-linux/4.9.2/include
End of search list.

Looks like you should provide your clang build with -stdlib option. One of -stdlib=libc++ or -stdlib=libstdc++ will probably work.

There are more details on your subject:

When is it necessary to use the flag -stdlib=libstdc++?


-stdlib=libstdc++ solved it for me. Here is my complete tasks.json config:

{
"tasks": [
    {
        "type": "shell",
        "label": "clang++ build active file",
        "command": "clang++",
        "args": [
            "-std=c++11",
            "-stdlib=libstdc++",
            "hello.cpp",
            "-o",
            "hello.out",
            "--debug"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
],
"version": "2.0.0"

For anyone Googling this & have a MacOS, here's the solution I found:

Add the following to your .bashrc/.zshrc file

export CPLUS_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1

This should fix it.