I'm running into an issue that seems to be caused by gcc not finding the headers that come with it. Not knowing much about C/GCC, I figured I'd check whether it's a safe assumption that the compiler should always be able to find those headers. Perhaps setting -I arguments overrides this? Or something else funky?
Original problem is at this issue in shoes on github.
Hi ! I've tried building on 10.8, with a non llvm gcc as stated in an other issue, and by tweaking a bit the rakefile to fetch the correct sdk in the correct place.
BUT
it still won't compile.
Here's the beginning of the error report (it's really long)
new-host-2:shoes benjamingattet$ rake gcc -I. -c -o shoes/app.o -Wall -I/usr/local/include -I/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin12.0.0 -I/usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1 -I/usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/x86_64-darwin12.0.0 -O -DRUBY_1_9 -DSHOES_QUARTZ -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -fpascal-strings -Os -w -pipe -march=core2 -msse4.1 -mmacosx-version-min=10.8 -fno-common -x objective-c -fobjc-exceptions -isysroot /Developer/SDKs/MacOSX10.8.sdk -arch x86_64 shoes/app.c shoes/app.c:5:18: error: glib.h: No such file or directory In file included from shoes/app.c:6: ./shoes/app.h:13:19: error: cairo.h: No such file or directory In file included from /usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/ruby.h:32, from ./shoes/app.h:14, from shoes/app.c:6: /usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:48:21: error: string.h: No such file or directory /usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:58:21: error: stdint.h: No such file or directory /usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:61:23: error: inttypes.h: No such file or directory /usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:64:20: error: stdarg.h: No such file or directory /usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:65:19: error: stdio.h: No such file or directory In file included from /usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:67, from /usr/local/Cellar/ruby/1.9.3-p194/include/ruby-1.9.1/ruby.h:32, from ./shoes/app.h:14,
GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets.
GCC needs to install corrected versions of some system header files. This is because most target systems have some header files that won't work with GCC unless they are changed. Some have bugs, some are incompatible with ISO C, and some depend on special features of other compilers.
The compiler will look in several places for header files that you include with the #include directive, depending on how you use it. If you use include with the angled brackets (e.g. #include <stdio. h> ) then the compiler will look in a series of "default" system-wide locations (see Search Path for details).
To check if an header file has been included or not in a C or C++ code, we need to check if the macro defined in the header file is being defined in the client code. Standard header files like math. h have their own unique macro (like _MATH_H ) which we need to check. Consider this example of checking if math.
gcc has a builtin list of directories it searches. And files like stddef.h
should be in one of these directories. A way to get that list is to compile a file (even an empty one) with --verbose. For instance here that gives:
$ touch foo.c
$ gcc --verbose -c foo.c
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5.1' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1)
COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic'
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/cc1 -quiet -v foo.c -D_FORTIFY_SOURCE=2 -quiet -dumpbase foo.c -mtune=generic -auxbase foo -version -fstack-protector -o /tmp/cc2QEK5o.s
GNU C (Ubuntu 4.4.3-4ubuntu5.1) version 4.4.3 (x86_64-linux-gnu)
compiled by GNU C version 4.4.3, GMP version 4.3.2, MPFR version 2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include-fixed
/usr/include
End of search list.
GNU C (Ubuntu 4.4.3-4ubuntu5.1) version 4.4.3 (x86_64-linux-gnu)
compiled by GNU C version 4.4.3, GMP version 4.3.2, MPFR version 2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 462394bb0ac77cba16b6fb6b32589358
COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic'
as -V -Qy -o foo.o /tmp/cc2QEK5o.s
GNU assembler version 2.20.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.20.1-system.20100303
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../:/lib/:/usr/lib/:/usr/lib/x86_64-linux-gnu/
COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic'
The part which interests you is
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/include-fixed
/usr/include
End of search list.
where you can see that the builtin path has some non existing directories and then the list of existing directories for both kinds of include directives.
If gcc has been installed at another place than the one it was compiled for, it used to have problems. But ISTR that recent gcc are more robust in those situation and start with the executable path.
At least you know where gcc is looking for files, and you may try to understand why they aren't there.
Note that gcc doesn't come with a full C library, only a few headers strongly tied to the implementation like stddef.h
and stdarg.h
are provided.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With