VC ++ Visual Studio在子目录中添加了.hpp文件,但获取“错误:无法打开源文件...” [英] VC++ Visual Studio added .hpp files in subdirectory but get "Error: cannot open source file ..."
问题描述
这让我疯狂 - 我已经在现有的VC ++项目源目录的根目录中的子目录中添加了一些.hpp文件。
Visual Studio抱怨错误:无法打开源文件...但如果我右键单击并选择打开文档,VS可以显示它。
我试过: p>
- 重新扫描解决方案似乎什么也不做。
- 添加现有项目
- 关闭项目和VStudio,希望它最终会发现我添加的目录/文件
VStudio抱怨当它能打开它们时,找不到这些文件?我的问题是这样的:我如何添加一个目录包含源文件到VC ++项目,以便链接器/编译器可以看到他们?
(disclaimer;从未使用过Visual Studio或许多Microsoft产品,所以我发现这一切都很陌生)
解决方法;
将文件添加到项目之外的目录,然后在属性 - >配置属性 - > C / C ++ - >常规中的其他包含目录中引用这些目录。 p>
为什么我不能在项目中添加额外的目录,并且Visual Studio重新扫描它们(像Eclipse刷新)。
This is driving me nuts - I've added a number of .hpp files in subdirectories in the root of an existing VC++ projects source directory.
Visual Studio complains "Error: cannot open source file ..." but if I right click on the and select open document, VS can display it.
I've tried:
- "Rescan solution" which appears to do nothing.
- Adding existing item (both on it's own and with a "filter" - which appears to be a directory?)
- Closing the project and VStudio in the vain hope it would eventually discover the directories/files I'd added
VStudio complains it cannot find these files when it is capable of opening them? My question is simply this: "How can I add a directory containing source files to a VC++ project such that the linker/complier can see them?
(disclaimer; i've never used Visual Studio before or many Microsoft products, so am finding this all very alien)
Workaround;
Add the files to a directory outside of the project and then reference those directories in the "Additional Include Directories" in Properties -> Configuration Properties -> C/C++ -> General.
Why I can't add additional directories within the project and have Visual Studio rescan them (like an Eclipse refresh) is beyond me.
这篇关于VC ++ Visual Studio在子目录中添加了.hpp文件,但获取“错误:无法打开源文件...”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!