Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010 can't find iostream

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

like image 843
JaxDragon Avatar asked Apr 07 '12 14:04

JaxDragon


People also ask

Where is the iostream library located?

As with other platforms, iostream is in the C++ standard library. The library itself is located in /usr/lib and the headers for the library are included with Xcode (see /Applications/Xcode. app/Contents/Developer/Toolchains/XcodeDefault. xctoolchain/usr/include/c++/v1/iostream).

How do I get iostream in C++?

The iostream library is part of the c++ standard library. If you're using vs, just install the c++ feature or directly install the visual c++ redistributable package. Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not.

Is iostream a library or header file?

iostream is a header file that provides declarations and prototypes that are an interface to part of the C++ standard library.

What can I use instead of iostream?

You can use <cstdio> instead of <iostream> , if you just need to output text. To print a string without formatting, you can use puts . Use printf to print with format and conversion specifiers.


1 Answers

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.

like image 126
the_mandrill Avatar answered Oct 29 '22 23:10

the_mandrill