Visual Studio 在哪里查找 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++ 包括目录下的工具 → 选项 → 项目和解决方案 → 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++ → General → 其他包含目录).
In your case, add the directory that the header is to the project properties (Project Properties → Configuration → C/C++ → General → Additional Include Directories).
相关文章