VS 2010 error - cannot open file “iostream”

前端 未结 4 840
灰色年华
灰色年华 2020-12-31 02:10

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

#include 
using std::cout;
using std::endl;

int main()
{         


        
相关标签:
4条回答
  • 2020-12-31 02:42

    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.

    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.

    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.

    0 讨论(0)
  • 2020-12-31 02:43

    I have no idea why this worked but I was getting this error and installing Visual Studio Power Commands solved this for me. This extension adds the Configuration Properties -> VC++ Directories that allows you to directly modify the ExecutableDirectories macro, it might have something to do with that.

    0 讨论(0)
  • 2020-12-31 02:47

    The system could not find the Visual C++ compiler (CL.exe)...

    Things you should try:

    • Rerun the Visual Studio 2010 installer and make sure you selected to install Visual C++ tools for your platform (either x86 or amd64).

    • Run the installer in repair mode.

    If this does not solve your problem:

    • Try to run Visual Studio 2010 Uninstall Utility (by Microsoft) and then try installing VS 2010 again.
    0 讨论(0)
  • 2020-12-31 02:59

    I had the same problem and found this page via a search, but I didn't quite grasp Ralf's answer about the user property sheet, and had no luck with re-installing. I think Ralf's answer would have worked for me, but I was looking at the "Property Pages" dialog that comes up when you right-click on a project in the Solution Explorer and choose "Properties". I didn't realize that it was different from the "Property Manager".

    So, I asked on the msdn forum and got an answer and a nice explanation of property sheets. The solution that worked for me was to edit the user property sheet in a text editor and delete all the paths, leaving it empty like this:

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

    The user property sheet is Microsoft.Cpp.Win32.user.props under <localappdata>\microsoft\msbuild\v4.0 where <localappdata> is c:\users\<username>\appdata\local under Win7.

    0 讨论(0)
提交回复
热议问题