Print GCC's include search path with gcc -xc -E -v -
Print the exact directories GCC 14 searches for headers by preprocessing empty input with gcc -xc -E -v -, with no source file needed.
When an #include resolves to the wrong header, guessing at -I flags wastes time. Ask the preprocessor instead: GCC 14.2 prints its search list when you run it verbosely over empty input, so no source file has to exist.
gcc -xc -E -v - < /dev/null#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/14/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.The list goes to stderr, which is why a pipe into grep seems to find nothing until you add 2>&1. The first group, for quoted includes, is empty here because stdin has no directory of its own; with a real file, that file's directory comes first. Your paths will differ by distribution and by the --with-sysroot GCC was built with. Change -xc to -xc++ to see the C++ list, which adds the libstdc++ directories ahead of the C ones. Any -I, -isystem or --sysroot flags you add to the command show up in the output, so it is also how you check what a build system really passes. The Preprocessor Options page covers -v and the include flags.