MacOS – homebrew gcc-5 fails to find any standard library


I am running os x version el capitan and have installed gcc5 via homebrew. However, compiling simple programs such as:

#include <stdio.h>

int main() {
    printf("Hello world\n");
    return 0;

leads to following error:

hello.c:1:19: fatal error: stdio.h: No such file or directory
compilation terminated.

This is the case for any other standard c library, such as time.h.

I've been reading around concerning where gcc looks to link against library, and according to I can get the list in the following manner:

echo | gcc-5 -Wp, -v

Which results in following paths:

Using built-in specs.
Target: x86_64-apple-darwin14.4.0

Configured with: ../configure
--build=x86_64-apple-darwin14.4.0 --prefix=/usr/local/Cellar/gcc/5.2.0
--enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-5
--with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr
--with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl
--with-system-zlib --enable-libstdcxx-time=yes
--enable-stage1-checking --enable-checking=release --enable-lto
--with-build-config=bootstrap-debug --disable-werror
--with-pkgversion='Homebrew gcc 5.2.0'
--enable-plugin --disable-nls --enable-multilib

Thread model: posix

gcc version 5.2.0 (Homebrew gcc 5.2.0)

Doing it for the os x gcc compiler, I get the following:

clang -cc1 version 7.0.0 based upon LLVM 3.7.0svn default target
ignoring nonexistent directory "/usr/include"

ignoring nonexistent directory "/Applications/"

ignoring nonexistent directory

include "..." search starts here:

include <...> search starts here:  /Applications/

(framework directory)
End of search list.

I do not know what these outputs mean, nor where my standard libraries are located. Could anybody help me configure gcc5 correctly?

Best Answer

Something is wrong with installation. Try updating Homebrew and reinstalling gcc-5. On El Capitan

Target: x86_64-apple-darwin14.4.0

should be

Target: x86_64-apple-darwin15.0.0

Works fine for me.