如何告诉 gcc 在头文件的包含文件夹中查找?

How to tell the gcc to look in the include folder for the header files?

我正在使用 c。我的项目 myProject/include 中有一个 include 文件夹,里面有我从 Internet 下载的 SDK 中的所有头文件。所以我的问题是如何告诉 gcc 在包含文件夹中查找头文件?

您可以将 -I 选项与 gcc 一起使用,以告知查找头文件的路径。

来自online gcc manual

-Idir

Add the directory dir to the head of the list of directories to be searched for header files. This can be used to override a system header file, substituting your own version, since these directories are searched before the system header file directories. [...]

您可以多次使用此选项,

[...] If you use more than one -I option, the directories are scanned in left-to-right order; the standard system directories come after.