Search code examples
gccinclude

gcc -print-search-dirs not printing /usr/include or similars


I'm having some trouble with gcc, conda and default directories in which to search header files. According to this answer it automatically searches for files in /usr/include.

According to man gcc:

-print-search-dirs
           Print the name of the configured installation directory and a list of program and library directories gcc searches---and don't do anything else.

But if I do gcc -print-search-dirs | grep -i include I get nothing. Why is that?


Solution

  • As the man documentation states, -print-search-dirs prints the GCC installation directory and lists the directories that GCC searches for programs (like the compiler, assembler, linker) and libraries (like the C or C++ runtimes, the program startup code). None of these directories contains header files, because they are not programs or libraries.

    If you want to list the directories in which GCC searches by default for header files, see this answer. Using that method you can confirm that /usr/include is one of the default directories, though not the only one nor the the first one.