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 https://stackoverflow.com/questions/17939930/finding-out-what-the-gcc-include-path-is 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/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include"

ignoring nonexistent directory

include "..." search starts here:

include <...> search starts here:  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include

(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?


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.

  • How do I change the target for gcc?
    – spurra
    Nov 26 '15 at 13:30
  • Never mind, I performed brew update, brew upgrade and reinstalled gcc-5, now I works. Thanks
    – spurra
    Nov 26 '15 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .