locked
fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

    Question

  •  Hi All:

     The story so far:

     I am having a we bit of trouble running

     the most difficult of all C++ programs the

     imfamous first C++ program Hello World!

     code:

     // Simple Hello World Console Application
    #include <iostream>
    using namespace std;
    int main()
    {
         cout << "\nHello World!\n" << endl;
         return 0;
    }

    And we get:

    ------ Build started: Project: Hello, Configuration: Debug Win32 ------

    Compiling...

    hello.cpp

    f:\program files\microsoft sdk\bin\hello\hello.cpp(2) : fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

    Build log was saved at "file://f:\Program Files\Microsoft SDK\Bin\Hello\Debug\BuildLog.htm"

    Hello - 1 error(s), 0 warning(s)

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

     What is really wrong this is the second

     time I have installed C++ and still is not

     running at all.

     

    Friday, June 09, 2006 12:08 AM

Answers

  • <iostream> is normally stored in the C:\Program Files\Microsoft Visual Studio 8\VC\include folder.  First check if it is still there.  Then choose Tools + Options, Projects and Solutions, VC++ Directories, choose "Include files" in the "Show Directories for"  combobox and double-check that $(VCInstallDir)include is on top of the list.

    Friday, June 09, 2006 7:00 PM
  • Check all of your code to make sure you've not included iostream.h anywhere.  C++ Express edition has no idea what iostream.h is, as it's not standard C++, this is the first edition to (finally) remove it altogether.

     

    Friday, June 09, 2006 12:32 AM
  • For using the above options take a look at http://msdn2.microsoft.com/en-us/library/8z9z0bx6.aspx & http://msdn2.microsoft.com/en-US/library/hdkef6tk.aspx

    Thanks,
    Ayman Shoukry
    VC++ Team
    Friday, June 09, 2006 4:12 PM

All replies

  • That is strange, I can't see that you are including stdio.h any where in your code. Are you sure this is the file you are compiling? Also, can you use the /P compiler option to preprocess hello.cpp (this will generate hello.i) and see where iostream.h is getting included.

    In addition, the build log should be helpful as well as using the /showincludes option to show the paths to the include files?

    Thanks,
    Ayman Shoukry
    VC++ Team
    Friday, June 09, 2006 12:19 AM
  • Check all of your code to make sure you've not included iostream.h anywhere.  C++ Express edition has no idea what iostream.h is, as it's not standard C++, this is the first edition to (finally) remove it altogether.

     

    Friday, June 09, 2006 12:32 AM
  •  Hi Ayman Shoukry:

     Not sure how to /P

     or \showincludes:

     Log file:

    Build Log      Build started: Project: Hello, Configuration: Debug|Win32
     Command Lines      Creating temporary file "f:\Program Files\Microsoft SDK\Bin\Hello\Debug\RSP00000115761592.rsp" with contents
    [
    /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /c /Wp64 /ZI /TP ".\hello.cpp"
    ]
    Creating command line "cl.exe @"f:\Program Files\Microsoft SDK\Bin\Hello\Debug\RSP00000115761592.rsp" /nologo /errorReport:prompt"
     Output Window      Compiling...
    hello.cpp
    f:\program files\microsoft sdk\bin\hello\hello.cpp(2) : fatal error C1083: Cannot open include file: 'iostream': No such file or directory
     Results      Build log was saved at "file://f:\Program Files\Microsoft SDK\Bin\Hello\Debug\BuildLog.htm"
    Hello - 1 error(s), 0 warning(s)
     

     Thank you in advance.

    Friday, June 09, 2006 3:52 PM
  • For using the above options take a look at http://msdn2.microsoft.com/en-us/library/8z9z0bx6.aspx & http://msdn2.microsoft.com/en-US/library/hdkef6tk.aspx

    Thanks,
    Ayman Shoukry
    VC++ Team
    Friday, June 09, 2006 4:12 PM
  • <iostream> is normally stored in the C:\Program Files\Microsoft Visual Studio 8\VC\include folder.  First check if it is still there.  Then choose Tools + Options, Projects and Solutions, VC++ Directories, choose "Include files" in the "Show Directories for"  combobox and double-check that $(VCInstallDir)include is on top of the list.

    Friday, June 09, 2006 7:00 PM
  • It would also be good to get projects out from under the installation location of the Platform SDK.  The default VC++ location for projects should be used, at least until operation is confirmed.  The Platform SDK being used may also be a little old.

    Since CL is looking for <iostream> and not <iostream.h>, I agree that it looks like the include paths aren't set up properly. 

    I think it would also be good to remove all modifications to VC++ for use of the Platform SDK until operation of VC++ is confirmed without it.  There is no need for it to compile programs that use only standard C/C++ libraries, and those should be tested first.

     - Dennis

    Saturday, June 10, 2006 7:23 AM
  • Hello, I have same problem.

    When I choose Tools + Option, Projects and Solutions, I did't see VC++ Directories. Only "General" and "VB Defaults"

    exist there. I think this is because I set VB as a defalut when I installed the IDE.

     

     

     

    Thanks for your help.

    Friday, September 14, 2007 3:00 PM
  • This forum is specifically for Visual C++ Express (either 2005 or the upcoming 2008 release) ... are you you have installed that product?

     

    Friday, September 14, 2007 3:18 PM
  • Lower left corner, click "Show All Settings".
    Friday, September 14, 2007 3:20 PM
  •  Jonathan Caves - MSFT wrote:
    (either 2005 or the upcoming 2008 release)

    Hi Jonathan .  Please, oh please don't do that.  Since the 2005 and 2008 Express editions can be run side by side (I'm told) (and not knowing when after 2008 RTM the 2005 downloads will become unavailable), mingling 2005 and 2008 Q&A in the same forum will be a nightmare.  Look at how much we have to go through now to find out what people are actually running in order to answer their questions and/or direct them to a more-appropriate Forum.

     

     - Dennis

    Friday, September 14, 2007 3:58 PM
  •  ardmore wrote:

    Hello, I have same problem.

    When I choose Tools + Option, Projects and Solutions, I did't see VC++ Directories. Only "General" and "VB Defaults"

    exist there. I think this is because I set VB as a defalut when I installed the IDE.

     

    Uh, there's some thread topic drift here.  What do you mean you have "the same problem?"

     

    Hans has given you advice about VS 2005 information in the Tools | Options pane.  And because you are running the full VS 2005 (and full VC++), you should check out those forums here.

     

    But if you are looking for iostream.h the problem is that for ISO Standard C++ (which 2005 supports), the name has no ".h" in it.  You need to use simply iostream.

     

     - Dennis

    Friday, September 14, 2007 4:03 PM
  • Ardmore,
    For your kind additional information, the ISO Standard C++ supports the inclusion of the iostream header as either
    #include <iostream>
     or
    #include "iostream"
    Both these directives seem to be compatible with Visual C++ 2005.

    Regards
    Juby
    Thursday, February 28, 2008 7:00 AM
  • I just got my first C++ lessons, so I tried that Hello World too, and I got that error too.
    But when I looked in the VC/include folder I saw it's <iostream> instead of <iostream.h>
    And then it worked ...

    But he doesnt recognize the namespace std. No bad, it works without using namespace std.

    • Proposed as answer by vasu.vlsi Friday, April 03, 2009 1:23 PM
    Wednesday, March 26, 2008 4:17 PM
  • Whozzz
    Welcome to the world of programming and it's definitely an intriguing one this. Congrats on getting your first progam upand  running. As they say, the toughest part is getting started. And did you mention that your compiler doesn't recognize namespace? I strongly recommend that you perform a double check on this issue. Because for several stream objects in Visual Studio 2005, prefixing it witt the namespace is mandatory.
    For eg:
    std::cout<<...;
    The above statement may be reconditioned to resemble:
    using namespace std;
    cout<<....;
    Try putting the namespace declarations above your main function immediately following the headers.
    Regards
    Juby
    • Proposed as answer by vasu.vlsi Friday, April 03, 2009 1:22 PM
    Thursday, March 27, 2008 1:06 AM
  • I am using 2008 edition , even I had such problem in including the iostream.h
    I modifed the code as below it worked.


    #include<iostream>

    using namespace std;

    int main()
    {
        cout<<"hello world"<<endl;
    }
    Friday, April 03, 2009 1:23 PM
  • I am also using 2008 edition , even I had such problem in including the iostream.h 
    I modifed the code as below it worked.


    #include<iostream>

    using namespace std;

    int main()
    {
        cout<<"hello world"<<endl;
    }

     

    this code is running correctly then why #include<iostream> is not working with other programmer's?

    Thursday, December 30, 2010 3:45 PM
  • i done same like that but same problem with me?

    what can i do?

    Thursday, December 30, 2010 4:13 PM
  • >i done same like that but same problem with me?

    Same like *what*? Which "same problem"?

    >what can i do?

    You can start by spending a little more time being
    a lot more specific.

    What is the error you're getting?
    *Exactly* - copy & paste it here, don't type it in.

    What is the code you're trying to compile/build?
    *Exactly* - copy & paste it here, don't type it in.

    Which compiler and which version are you using?
    It's important - *always* specify that.

    What kind of project are you using to try the build?
    If you selected from an available project template,
    which one?

    - Wayne
    Thursday, December 30, 2010 7:19 PM
  • I have same problem in Framework 2.0 sdk:fatal error C1083 1.below is command line: C:\Program Files\Microsoft.NET\SDK\v2.0>cl simple.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. simple.cpp simple.cpp(8) : fatal error C1083: Cannot open include file: 'iostream': No such file or directory 2.The set in sdkvars.bat is following: @Set Path=C:\Program Files\Microsoft.NET\SDK\v2.0\Bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\bin;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\vcpackages;%PATH% @Set LIB=C:\Program Files\Microsoft Visual Studio 8\VC\lib;C:\Program Files\Microsoft.NET\SDK\v2.0\Lib;%LIB% @Set INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\include;C:\Program Files\Microsoft.NET\SDK\v2.0\include;%INCLUDE% @Set NetSamplePath=C:\Program Files\Microsoft.NET\SDK\v2.0 @Set VCBUILD_DEFAULT_CFG=Debug^|Win32 @Set VCBUILD_DEFAULT_OPTIONS=/useenv @echo Setting environment to use Microsoft .NET Framework v2.0 SDK tools. @echo For a list of SDK tools, see the 'StartTools.htm' file in the bin folder. 3.the code in simple.cpp is: #include <iostream> using namespace std; int main() { std::cout<<"hello world!This is a native C++ program.\n"; system("PAUSE"); return 0; } 4.by the way, the code is complied by dev c++. result is OK. But SDK is not OK. I also make some code for C# hello. there is not problem for CSC .......*.CS with this SDK. Only C++ has this problem. thanks for you support for solving this problem.
    Sunday, May 22, 2011 5:10 PM
  • >I have same problem in Framework 2.0 sdk:
    >fatal error C1083: Cannot open include file: 'iostream':
    >But SDK is not OK.

    The iostream header has nothing to do with the .NET
    Framework SDK. It is part of the C++ Standard Library
    and should be in the ..\VC\INCLUDE subdirectory.

    Make sure it's there, and make sure you have set the
    name correctly in the environment variables.

    Try specifying the include path as an option:

    cl /I"C:\Program Files\Microsoft Visual Studio 8\VC\include" simple.cpp

    - Wayne
    Sunday, May 22, 2011 6:22 PM
  • I do according to your suggestion, but result as below: Setting environment to use Microsoft .NET Framework v2.0 SDK tools. For a list of SDK tools, see the 'StartTools.htm' file in the bin folder. C:\Program Files\Microsoft.NET\SDK\v2.0>cl /I"C:\Program Files\Microsoft Visual Studio 8\VC\include" simple.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. simple.cpp simple.cpp(8) : fatal error C1083: Cannot open include file: 'iostream': No such file or directory C:\Program Files\Microsoft.NET\SDK\v2.0> one question: How could I repair the files in "C:\Program Files\Microsoft Visual Studio 8\VC\include", if there are some problems of this folder?
    Monday, May 23, 2011 3:00 PM
  • Change #include <iostream.h> to #include <iostream>
    Add "using namespace std;" below the #include statements.


    for eg;-

    #include <iostream>
    #include <string>
    using namespace std;
    .

    .

    .

    .

    .

    • Proposed as answer by Karthik Nair Wednesday, August 24, 2011 10:06 AM
    Wednesday, August 24, 2011 10:06 AM
  • i performed every single step described , but still the same problem " cannot open include file.........
    Monday, October 29, 2012 8:03 AM
  • Don't you think it would be a good idea to show us the exact include directive and the complete text of the error message.
    Monday, October 29, 2012 8:18 PM