Visual Studio 在哪里寻找 C++ 头文件?

2022-01-11 00:00:00 visual-studio header c++

我从 SourceForge(HoboCopy,如果你好奇的话)检查了一个 C++ 应用程序的副本并尝试编译它.

I checked out a copy of a C++ application from SourceForge (HoboCopy, if you're curious) and tried to compile it.

Visual Studio 告诉我它找不到特定的头文件.我在源码树中找到了这个文件,但是我需要把它放在哪里,这样编译的时候才能找到呢?

Visual Studio tells me that it can't find a particular header file. I found the file in the source tree, but where do I need to put it, so that it will be found when compiling?

有特殊目录吗?

推荐答案

Visual Studio 按以下顺序查找标头:

Visual Studio looks for headers in this order:

  • 在当前源目录中.
  • 在项目属性的附加包含目录中(项目 -> [项目名称] 属性,在 C/C++ | 常规下).
  • 在 Visual Studio C++ Include 目录下 Tools → Options → Projects and Solutions → VC++ 目录.
  • 在新版本的 Visual Studio (2015+) 中,上述选项已弃用,默认包含目录列表可在 Project Properties → Configuration → 获得VC++ 目录
  • In the current source directory.
  • In the Additional Include Directories in the project properties (Project -> [project name] Properties, under C/C++ | General).
  • In the Visual Studio C++ Include directories under Tools → Options → Projects and Solutions → VC++ Directories.
  • In new versions of Visual Studio (2015+) the above option is deprecated and a list of default include directories is available at Project Properties → Configuration → VC++ Directories

在您的情况下,将标题所在的目录添加到项目属性中(Project Properties → Configuration → C/C++ → 常规 → 其他包含目录).

In your case, add the directory that the header is to the project properties (Project Properties → Configuration → C/C++ → General → Additional Include Directories).

相关文章