Home > Article > Backend Development > How do I tell GCC to search for header files in specific directories?
When working with complex codebases spread across multiple folders, one may encounter issues with GCC locating the required header files for compilation. This guide addresses the specific problem faced by the user in including header files from various subdirectories within a larger project directory.
To instruct GCC to search for header files in a specific path, the -I flag is employed. The syntax is as follows:
gcc -I<path> <source file>
For the given code example with header files located under /home/me/development/skia, the proper compilation command would be:
gcc -c -I/home/me/development/skia sample.c
With this flag, GCC will search for the header files in /home/me/development/skia and its subdirectories, allowing the code to be compiled successfully.
The above is the detailed content of How do I tell GCC to search for header files in specific directories?. For more information, please follow other related articles on the PHP Chinese website!