問題描述
我從 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).
這篇關于Visual Studio 在哪里查找 C++ 頭文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!