VS 2010错误 - 无法打开文件“iostream” [英] VS 2010 error - cannot open file "iostream"

查看:1659
本文介绍了VS 2010错误 - 无法打开文件“iostream”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚从VS2005迁移到VS2010,无法编译一个简单的程序。

I've just migrated from VS2005 to VS2010 and it fails to compile a simple program.

#include <iostream>
using std::cout;
using std::endl;

int main()
{
    cout << "Hello Visual Studio 2010 :)" << endl;
}

错误 -

1  error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified.
2  IntelliSense: cannot open source file "iostream"
3  IntelliSense: name followed by '::' must be a class or namespace name
4  IntelliSense: name followed by '::' must be a class or namespace name
5  IntelliSense: identifier "cout" is undefined
6  IntelliSense: identifier "endl" is undefined

PS :我完全不熟悉VS2010,但在VS 2005中有经验。

PS: I'm completely new to using VS2010 but have experience in VS 2005.

以下是我在用户属性表下从VS2005添加到VS2010的目录列表

Here are lists of directories that I added from VS2005 to VS2010 under 'user property sheet'

可执行文件 -

$(VCInstallDir)bin; $(VSInstallDir)Common7\Tools\bin; $(VSInstallDir)Common7\tools; $(VSInstallDir)Common7\ide; $(VSInstallDir); $(VSInstallDir)\SDK\v2.0\bin

包括 -

$(VCInstallDir)include; $(VCInstallDir)atlmfc\include; $(FrameworkSDKDir)include

库 - b

$(VCInstallDir)lib; $(VCInstallDir)atlmfc\lib; $(VCInstallDir)atlmfc\lib\i386; $(FrameworkSDKDir)lib; $(VSInstallDir); $(VSInstallDir)lib

源 - b

$(VCInstallDir)atlmfc\src\mfc; $(VCInstallDir)atlmfc\src\mfcm; $(VCInstallDir)atlmfc\src\atl; $(VCInstallDir)crt\src


推荐答案

在几个不同的机器上遇到相同的问题,其中已经安装了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的一个新实例
- Create新的控制台应用程序与def设置。
- 尝试编译:应该有一些错误
- 打开Property Manager
- 打开项目的Microsoft.Cpp.Win32.user属性表
- 单击on 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.

这篇关于VS 2010错误 - 无法打开文件“iostream”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆