且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

VS 2010 错误 - 无法打开文件“iostream"

更新时间:2022-04-19 09:18:49

我在几台不同的机器上遇到了同样的问题,这些机器已经安装了其他版本的 VS(2005、2008).我最终也收到了各种奇怪的错误.

I've run into the same issue on a couple of different machines where there were other versions of VS (2005, 2008) already installed. I ended up also getting all sorts of strange errors.

我发现以下技巧对我有用,也许它也适用于您的情况:- 打开一个新的 VS2010 实例- 使用 def 设置创建新的控制台应用程序.- 尝试编译:应该有一些错误- 打开物业经理"- 调出项目的 Microsoft.Cpp.Win32.user 属性表- 单击 VC++ 目录- 单击可执行目录"字段.那应该显示一个下拉列表,单击下拉列表并选择编辑".您应该会看到一堆继承的值,这些值应该包含与上面列出的目录类似的所有必需目录.取消选中从父级或项目默认值继承"选项.重新检查并单击确定".
- 对包含、库目录等重复此操作.- 点击应用"和确定"- 重建项目并检查它是否有效.

I found the following trick worked for me, maybe it will work in your case too: - Open a new instance of VS2010 - Create new console application with the def settings. - Try compile: there should be some errors - Open the "Property Manager" - Bring up the Microsoft.Cpp.Win32.user property sheet of the project - Click on VC++ Directories - Click on the "Executable Directories" field. That should display a drop down, click on the drop down and select "Edit". You should see a bunch of inherited values that supposedly contain all the required directories similar to the ones you listed above. Uncheck the "Inherit from parent or project defaults" option. Recheck it and click "Ok".
- Repeat this for the includes, library directories, etc. -Click on "Apply" and "Ok" - Rebuild the project and check if this worked.

我只需要这样做一次.关闭VS并创建一个新项目后,我就可以编译了.在我发现这一点之前,我手动删除了所有继承的值,并为所有 VS 和 SDK 目录添加了绝对路径.这也有效,但需要做更多的工作.

I only needed to do this once. After closing VS and creating a new project, I could just compile. Before I discovered this, I manually removed all inherited values and added absolute paths to all the VS and SDK directories. That also worked, but was a lot more work.