Home > Backend Development > C++ > body text

How do I tell GCC to search for header files in specific directories?

Patricia Arquette
Release: 2024-10-30 02:02:02
Original
430 people have browsed it

How do I tell GCC to search for header files in specific directories?

Including Header Files in GCC Search Path

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>
Copy after login

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template