I was just bitten by this.  I tried to upgrade from clang-3.4 to
clang-3.5, and was unable to compile anything because the standard
headers were not found.   I then downgraded back to clang-3.4, and was
surprised to find that to be broken as well.  Since at that point I was
stuck, I plowed on until I found a solution.

The issue seems related to the fact that gcc-4.9 exists at this point in
time, but g++-4.9 does not.  I think this means it only affects those
who have partially upgraded to gcc-4.9 (the C compiler, but not the C++
compiler).  Clang is searching for the standard C++ header in
directories that don't exist and not finding them.   There also seem to
be issues where Clang is searching only for /usr/include/c++ without
adding an appropriate version number.

One fix is to add symlinks until Clang can find the files it's looking
for.

The currently searched header directories can be found with: 
clang++ -E -x c++ - -v < /dev/null

Assuming a test file 'file.cpp' that includes a failing header, you can see 
where g++ is successfully finding a header (and Clang is failing) like this:
strace -f g++  file.cpp -std=gnu++11 -o file.o  2>&1 | grep header
strace -f clang++  file.cpp -std=gnu++11 -o file.o  2>&1 | grep header

There are several ways of helping Clang to find the headers it is
looking for, all of varying degree of likelihood to break other things.
I decided the path of least harm was to create symlinks like this:

$ ls -l /usr/include/c++/
lrwxrwxrwx  1 root root     3 Dec 20 15:50 backward -> 4.8
lrwxrwxrwx  1 root root    37 Dec 20 15:56 x86_64-linux-gnu -> 
/usr/include/x86_64-linux-gnu/c++/4.8

Once you solve the issue of finding header files, you then won't be able to 
find libstdc++.so.  I fixed that with this:
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/4.8 /usr/local/lib/x86_64-linux-gnu

Now that I've done this, both clang-3.4 and clang-3.5 will work,
although not simultaneously because Ubuntu supports multiple versions of
GCC but not of Clang.   Note that this is just an ugly workaround for a
bug that should be fixed by Ubuntu.  Once this is fixed, these steps
will be unnecessary, and possibly hazardous.  Personally, I think that
Ubuntu should support having multiple versions of Clang installed, and
rather than deinstalling one version to install another.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1242300

Title:
  Clang cannot locate standard header files

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/llvm-defaults/+bug/1242300/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to