C++ – Visual Studio 2010 can’t find iostream

cvisual studio

I just installed Visual Studio 2010, and wanted to test it out by writing a hello world application.

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello World!" << endl;

    return 0;
}

After trying to compile this I get this error

error C1083: Cannot open include file: 'iostream': No such file or directory

Here are my visual studio include directories

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

And my library directories

$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib

Best Answer

If you are unable to build a simple hello world application then it suggests that either Visual Studio or the Windows SDK isn't installed correctly. Have you downloaded and installed the Windows SDK? (note: if you need to build for XP you might need to use the Win7 SDK instead)

I seem to recall that after installing the Windows SDK you may need to 'integrate' it for use with VS2010. Each version of Visual Studio can have a different default SDK that it builds against. You may need to run the SDK Configuration Tool to register it for use with VS2010. Alternatively, you might need to check the 'Platform Toolset' settings in the project, as described here

Ultimately, once that is correctly setup then you should be able to build simple C++ apps without any further configuration.