Reputation: 5077
I am working on OSX Yosemite and I installed gcc-4.8
from homebrew.
The following program fails upon compilation (e.g. gcc-4.8 main.c
):
#include <stdio.h>
int main(void)
{
printf("hello world");
return 0;
}
with the error :
main.c:8:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
and
$`gcc-4.8 -print-prog-name=cc1` -v
yields
ignoring nonexistent directory "/usr/local/Cellar/gcc48/4.8.4/lib/gcc/4.8/gcc/x86_64-apple-darwin14.3.0/4.8.4/../../../../../../x86_64-apple-darwin14.3.0/include"
ignoring nonexistent directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/Cellar/gcc48/4.8.4/lib/gcc/4.8/gcc/x86_64-apple-darwin14.3.0/4.8.4/include
/usr/local/include
/usr/local/Cellar/gcc48/4.8.4/include
/usr/local/Cellar/gcc48/4.8.4/lib/gcc/4.8/gcc/x86_64-apple-darwin14.3.0/4.8.4/include-fixed
/System/Library/Frameworks
/Library/Frameworks
End of search list.
and
$ find /usr/local/ -name "stdio.h" -print
yields
/usr/local//Cellar/gcc/5.2.0/include/c++/5.2.0/tr1/stdio.h
/usr/local//Cellar/gcc/5.2.0/lib/gcc/5/gcc/x86_64-apple-darwin14.4.0/5.2.0/include/ssp/stdio.h
/usr/local//Cellar/gcc48/4.8.4/include/c++/4.8.4/tr1/stdio.h
/usr/local//Cellar/gcc48/4.8.4/lib/gcc/4.8/gcc/x86_64-apple-darwin14.3.0/4.8.4/include/ssp/stdio.h
/usr/local//include/c++/4.8.4/tr1/stdio.h
/usr/local//lib/gcc/4.8/gcc/x86_64-apple-darwin14.3.0/4.8.4/include/ssp/stdio.h
Now I know I can pass -I /path/to/directory
to get the compiler to find the correct header files, but for goodness sake this is stdio.h
! I don't want to have to do this for silly little programs. How can I fix this flaw?
Upvotes: 3
Views: 1801
Reputation: 5077
I ended up removing the brew formula and reinstalling it. It now works, I'm still not clear as to where / when it got corrupted.
EDIT Turns out this issue has occurred for me several times now. It happens every time that I upgrade OSX or Xcode.
Upvotes: 2