Standard headers cannot be found when compiling with Clang

Hello All,

I am a beginner of clang. I installed clang 3.6 with llvm 3.6, but I found my clang cannot work as expected.
For the next simple program test.c:

#include <stdio.h>
int main() {return 0;}

$ clang -c test.c

Hello All,

I am a beginner of clang. I installed clang 3.6 with llvm 3.6, but I found
my clang cannot work as expected.
For the next simple program test.c:

#include <stdio.h>
int main() {return 0;}

$ clang -c test.c

I got the next information:

fatal error: 'stdio.h' file not found
#include <stdio.h>
             ^
1 error generated.

what's wrong? I found other standard headers are also cannot be found.
Any suggestion is OK. Thank you in advance.

What operating system are you using?

What's the output of "clang -v -c test.c"?

I use ubuntu,

$ uname -a
Linux novice 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

and this is the output of ‘clang -v -c’

$ clang -v -c test.c
clang version 3.6.0 (tags/RELEASE_360/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
“/home/novice/installed/llvm-3.6.0.src/Release+Asserts/bin/clang” -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name t1.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -coverage-file /home/novice/installed/llvm-3.6.0.src/Release+Asserts/bin/t1.c -resource-dir “/home/novice/installed/llvm-3.6.0.src/Release+Asserts/bin/${CLANG_RESOURCE_DIR}” -isysroot “${DEFAULT_SYSROOT}” -c-isystem /home/novice/.install/include -cxx-isystem /home/novice/.install/include -internal-isystem “${DEFAULT_SYSROOT}/usr/local/include” -internal-isystem “/home/novice/installed/llvm-3.6.0.src/Release+Asserts/bin/${CLANG_RESOURCE_DIR}/include” -internal-externc-isystem “${C_INCLUDE_DIRS}” -fdebug-compilation-dir /home/novice/installed/llvm-3.6.0.src/Release+Asserts/bin -ferror-limit 19 -fmessage-length 205 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o t1.o -x c /home/novice/installed/llvm-3.2.src/examples/test/t1.c
clang -cc1 version 3.6.0 based upon ${BACKEND_PACKAGE_STRING} default target x86_64-unknown-linux-gnu
ignoring nonexistent directory “/home/novice/.install/include”
ignoring nonexistent directory “/home/novice/.install/include”
ignoring nonexistent directory “${DEFAULT_SYSROOT}/usr/local/include”
ignoring nonexistent directory “/home/novice/installed/llvm-3.6.0.src/Release+Asserts/bin/${CLANG_RESOURCE_DIR}/include”
ignoring nonexistent directory “${C_INCLUDE_DIRS}”
#include “…” search starts here:
End of search list.
/home/novice/installed/llvm-3.2.src/examples/test/t1.c:2:10: fatal error: ‘stdio.h’ file not found
#include <stdio.h>
^
1 error generated.

I put clang in llvm-3.6.0.src/toos/…

I use ubuntu,

I don't think Clang ever could find proper includes here. See the bugs like:

It works fine, it just doesn't know where to find the correct stdlib headers, so you have to use an -I argument to tell it where your stdlib headers are (arch-specific on Debians/Ubuntus/etc).

Cheers,
Matthew Brush

I cannot solve this problem by all the methods I know. I don’t know why. Now I just reinstall llvm and clang, and it wokrs.
Thanks for your help!