C++ VS 2010错误-无法打开文件;iostream“;

C++ VS 2010错误-无法打开文件;iostream“;,c++,visual-studio-2010,compilation,windows-xp-sp3,C++,Visual Studio 2010,Compilation,Windows Xp Sp3,我刚刚从VS2005迁移到VS2010,它无法编译一个简单的程序 #include <iostream> using std::cout; using std::endl; int main() { cout << "Hello Visual Studio 2010 :)" << endl; } PS:我对使用VS2010完全不熟悉,但对VS2005有经验 以下是我在“用户属性表”下从VS2005添加到VS2010的目录列表 可执行文件- 1 e

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

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

int main()
{
    cout << "Hello Visual Studio 2010 :)" << endl;
}
PS:我对使用VS2010完全不熟悉,但对VS2005有经验

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

可执行文件-

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
$(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
$(VCInstallDir)lib; $(VCInstallDir)atlmfc\lib; $(VCInstallDir)atlmfc\lib\i386; $(FrameworkSDKDir)lib; $(VSInstallDir); $(VSInstallDir)lib
$(VCInstallDir)atlmfc\src\mfc; $(VCInstallDir)atlmfc\src\mfcm; $(VCInstallDir)atlmfc\src\atl; $(VCInstallDir)crt\src
包括-

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
$(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
$(VCInstallDir)lib; $(VCInstallDir)atlmfc\lib; $(VCInstallDir)atlmfc\lib\i386; $(FrameworkSDKDir)lib; $(VSInstallDir); $(VSInstallDir)lib
$(VCInstallDir)atlmfc\src\mfc; $(VCInstallDir)atlmfc\src\mfcm; $(VCInstallDir)atlmfc\src\atl; $(VCInstallDir)crt\src
库-

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
$(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
$(VCInstallDir)lib; $(VCInstallDir)atlmfc\lib; $(VCInstallDir)atlmfc\lib\i386; $(FrameworkSDKDir)lib; $(VSInstallDir); $(VSInstallDir)lib
$(VCInstallDir)atlmfc\src\mfc; $(VCInstallDir)atlmfc\src\mfcm; $(VCInstallDir)atlmfc\src\atl; $(VCInstallDir)crt\src
来源-

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
$(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
$(VCInstallDir)lib; $(VCInstallDir)atlmfc\lib; $(VCInstallDir)atlmfc\lib\i386; $(FrameworkSDKDir)lib; $(VSInstallDir); $(VSInstallDir)lib
$(VCInstallDir)atlmfc\src\mfc; $(VCInstallDir)atlmfc\src\mfcm; $(VCInstallDir)atlmfc\src\atl; $(VCInstallDir)crt\src

系统找不到Visual C++编译器(C.exe)…< /P> 你应该尝试的事情:

    > Pr>重新运行VisualStudio 2010安装程序,并确保您选择为平台安装VisualC++工具(x86或AMD64)。

  • 在修复模式下运行安装程序

如果这不能解决您的问题:

  • 尝试运行,然后再次尝试安装VS 2010

我在已经安装了其他版本的VS(2005、2008)的两台不同机器上遇到了相同的问题。我最后也犯了各种奇怪的错误

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


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

我也遇到了同样的问题,通过搜索找到了这个页面,但我没有完全掌握Ralf关于用户属性表的答案,也没有成功地重新安装。我认为Ralf的答案对我来说是可行的,但我看到的是“属性页”对话框,当您在解决方案资源管理器中右键单击一个项目并选择“属性”时会出现该对话框。我没有意识到它与“物业经理”不同

所以,我在msdn论坛上问了一下,得到了答案。对我有效的解决方案是在文本编辑器中编辑用户属性表并删除所有路径,将其保留为空,如下所示:

<?xml version="1.0" encoding="utf-8"?> 
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

</Project>

用户属性页位于下面的
Microsoft.Cpp.Win32.user.props
\microsoft\msbuild\v4.0
其中

Win7下的
c:\users\\appdata\local

我不知道为什么会这样,但我得到了这个错误,安装为我解决了这个问题。此扩展添加了Configuration Properties->VC++目录,允许您直接修改ExecutableDirectories宏,这可能与此有关。

是否包含路径包括默认头文件的文件路径?是的,
CL
是链接器。如果你的编译器找不到它是乱七八糟的。这确实使这更像是一个系统管理员(Serverfault.com)问题,而不是一个编程(SO)问题。@T.E.D.:不,
CL.exe
是Visual Studio中的编译器,链接器名为
LINK.exe
。恕我直言,SLaks评论怎么会有11票?这完全没有用。回答得很好,拉尔夫。。。从错误中我们可以看出,这里的主要问题是VisualStudio没有在属性页中定义的可执行目录列表中找到编译器文件。确保选中“从父级或项目默认值继承”选项后,确保$(ExecutablePath)显示在“可执行目录”字段的末尾。这才是你真正需要的。如果修改每个文件的单个项目设置,还需要确保为该项目添加$(ExecutablePath)。这对我来说很有效!我会为此痛苦好几个星期!谢谢