Discussion:
Cannot open include file: 'iostream'
(too old to reply)
NewToVC++
2004-02-01 22:21:07 UTC
Permalink
Hello,

I have a very basic question. I am an experienced Java developer trying to pick up Visual C++. My problem is that the compiler is not able to find the iostream header file, when compiling from the command line. I hope someone can point out what my mistake. Please help. I wonder if there is some compiler flag that I need to use? I searched the folders under .NET Redist and SDK (Visual Studio .NET) installations on my computer, and I could not find any iostream.h. These are the steps I followed:

Step 1. On Windows 2000 SP 3, I just dowloaded and installed MS .NET Redistributable 1.1 and MS .NET SDK 1.1

Step 2. In a cmd window, I ran the batch file to setup environment:
D:\>"c:/Program Files/Microsoft.NET/SDK/v1.1/Bin/sdkvars.bat"

D:\>Set Path=C:\Program Files\Microsoft.NET\SDK\v1.1\Bin\;C:\WINNT\Microsoft.NET\Framework\v1.1.4322\;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\;C:\j2sdk1.4.1_01\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\Symantec\pcAnywhere\;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\WINNT\Microsoft.NET\Framework\v1.1.4322;C:\;C:\ERCDTMP;C:\ERCDTMP\BIN;C:\ERCDTMP\TOOLS\PT1

D:\>Set LIB=C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\;"C:\Program Files\Microsoft.NET\SDK\v1.1\Lib\";

D:\>Set INCLUDE=C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\;"C:\Program Files\Microsoft.NET\SDK\v1.1\include\";

D:\>Set NetSamplePath=C:\PROGRA~1\MICROS~2.NET\SDK\v1.1\

Step 3. I created a file named "hello.c" with this bare-bones code:

#include <iostream>
int main () {
return 0;
}

Step 4. I tried to compile it, but failed with this error:
d:\>cl hello.c
cl hello.c
Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

hello.c
hello.c(1) : fatal error C1083: Cannot open include file: 'iostream': No such file or directory
Jeff Partch [MVP]
2004-02-01 22:37:05 UTC
Permalink
Post by NewToVC++
Hello,
I have a very basic question. I am an experienced Java developer trying
to pick up Visual C++. My problem is that the compiler is not able to find
the iostream header file, when compiling from the command line. I hope
someone can point out what my mistake. Please help. I wonder if there is
some compiler flag that I need to use? I searched the folders under .NET
Redist and SDK (Visual Studio .NET) installations on my computer, and I
Post by NewToVC++
Step 1. On Windows 2000 SP 3, I just dowloaded and installed MS .NET
Redistributable 1.1 and MS .NET SDK 1.1
Post by NewToVC++
D:\>"c:/Program Files/Microsoft.NET/SDK/v1.1/Bin/sdkvars.bat"
Not really sure, what comes with the .NET SDK. Do you have VC installed? If
so, try running the 'vcvars32.bat' file in 'C:\Program Files\Microsoft
Visual Studio .NET 2003\Vc7\bin' instead.
--
Jeff Partch [VC++ MVP]
NewToVC++
2004-02-01 23:06:06 UTC
Permalink
Thanks for your response. I am getting the exact same with Visual C++ 7 on a machine (W2K SP4) with Visual Studio .NET installed. I ran the vcvars32.bat as you suggested, and then tried cl hello.c and I got the same error. Any further ideas

Am I supposed to be able to search in some folders and be able to locate a file named "iostream"? I searched on my computer and could not find it

Thanks again.
Carl Daniel [VC++ MVP]
2004-02-01 23:24:58 UTC
Permalink
Post by NewToVC++
Thanks for your response. I am getting the exact same with Visual
C++ 7 on a machine (W2K SP4) with Visual Studio .NET installed. I
ran the vcvars32.bat as you suggested, and then tried cl hello.c and
I got the same error. Any further ideas?
Am I supposed to be able to search in some folders and be able to
locate a file named "iostream"? I searched on my computer and could
not find it.
1. The C++ compiler included in the .NET SDK does not include the C++
standard library, nor MFC or ATL.

2. The C++ standard library headers (such as 'iostream') are in
{vs-instsall-dir}/vc7/include. If they're not there, you have an incomplete
installtion.

3. Compiling from the IDE, these directories will be on the INCLUDE path by
default.

4. Compiling from the command-line, running
{vs-install-dir}/vc7/bin/vcvars32.bat will add this and other directories to
the INCLUDE path and make appropriate additions to LIBPATH, etc as well. Of
course, you have to continue to use this same console window to compile
files since only child processes of that particular console window will
inherit the modified environment.

5. Files with an extension of .c are by default considered to be C, not C++.
Either rename the file hello.cpp or compile it with cl /TP hello.c to force
the compiler to interpret as C++.

If you're still having troubles, post again - I'm sure someone will be able
to figure out what's going on eventually.

-cd
a.m.a
2004-02-02 02:36:57 UTC
Permalink
Are saying what i think your saying:

1. The C++ compiler included in the .NET SDK does not include the C++
standard library, nor MFC or ATL.

is this for real ?? I thought ATL was a great dev tool and so are STD
libraries lol
Carl Daniel [VC++ MVP]
2004-02-02 03:42:29 UTC
Permalink
Post by Carl Daniel [VC++ MVP]
1. The C++ compiler included in the .NET SDK does not include the C++
standard library, nor MFC or ATL.
is this for real ?? I thought ATL was a great dev tool and so are STD
libraries lol
Of course it's for real. Those are not part of .NET, therefore they're not
included in the (FREE) .NET SDK. You have to buy some edition of Visual C++
to get those libraries.

-cd
a.m.a
2004-02-02 18:22:55 UTC
Permalink
Ok , sorry, i thought you guys were talking about vc.net, not the sdk, my
bad.

NewToVC++
2004-02-02 04:26:09 UTC
Permalink
{vs-instsall-dir}/vc7/include does not have iostream. I opened the VS .NET IDE and the About dialog showed only Visual C# in the list of installed applications. Probably means that the complete Visual C++ is not installed, and I need to look into getting it installed

Appreciate your prompt help.
Continue reading on narkive:
Loading...