0
votes

I am trying to compile a simple "hello world" program with gcc on macOS and for some reason I get the error "fatal error: stdio.h: No such file or directory"

The interesting thing is that, if I compile using the entire path, so

/usr/bin/gcc hello.c

then everything works out fine. Although, if I run

which gcc

I get

/usr/local/bin/gcc

and with this path the compilation gives me the same error.

I used homebrew to install gcc, Xcode is up do date.

I really need to get this work, because I need to compile a code that uses both fortran and c modules, nd I have no idea how to modify the Makefile. Fortran compilation with gfortran works out fine. Thanks!

1

1 Answers

0
votes

Follow steps

Step 1 : run xcode-select --install

Step2 : Added this line export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

to your .bash_profile file.

Step 3 : restart the terminal.