2

I was bothered by the error

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

for quite a while, I tried my best to search all the relevant cases but couldn't find a good answer for me.

My situation is, I have a simple piece of code with a couple of dependencies to build, after setting up all the include folders, I'm just experiencing this compiler error all the time. Two weird questions I cannot answer,

  1. There is another win32 console project somebody else set up for this project, working! I'm trying to copy all of his settings (the command line options are exactly the same, all env variables are same, and I run two projects on same visual studio), but just have this 1083 error in my own project.

  2. I was playing around with the settings, one time I changed the platform from Active(Win32) to Win32, then suddenly the compiling works, but after that time I couldn't reproduce it any more.

The thing is, I'm guessing VS in my project might go to a wrong directory

C:\Program Files\Microsoft Visual Studio 8\VC\include instead of C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include

not quite sure, and earlier I was trying to compiling using a building script and make files, same error happened because there people didn't update the correct VS directory.

Sorry I couldn't provide the source code here, and it won't be helpful either since it has a couple of levels of dependency. But I hope based on my description some one might give some idea which direction should I go or spend time on.

Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
Derek
  • 1,085
  • 2
  • 20
  • 36
  • Sorry I didn't make it clear enough, in my code I use iostream only, but down the way of include dependency, some other files using iostream.h which caught the error, I found that by printing out include tree. Another thing is, the other project I mentioned is working, having the same dependency. – Derek Nov 22 '11 at 00:06
  • possible duplicate of [C1083: Cannot open include file: math.h: No such file or directory](http://stackoverflow.com/questions/24186647/c1083-cannot-open-include-file-math-h-no-such-file-or-directory) – dagronlund May 06 '15 at 23:14

4 Answers4

2

iostream.h is deprecated, it should be just iostream:

#include <iostream>

See <iostream> vs. <iostream.h> vs. "iostream.h"

Community
  • 1
  • 1
Anders Abel
  • 67,989
  • 17
  • 150
  • 217
2

In this version of visual studio (and also in any modern C++ IDE) standard library headers are named without any suffices (iostream instead of iostream.h, string instead of string.h, etc) Also, C library headers are named like cxxx instead of xxx.h, for example, you should include cstdlib instead of stdlib.h

zebrilo
  • 134
  • 3
1

When you say that you ran your project and the other person's (working) project on the "same visual studio", do you mean the same installation or the same version? If they're not on the same installation, then even if the project settings are copied exactly, it could be that the installation settings are different and that that's what's causing the problem. This may be a long shot, but I'll do my best to explain.

I came across your question because I had a slightly similar problem. Even without dependencies, I couldn't get a simple "Hello, World" program to compile. I used iostream without ".h" as many people suggested and still got C1083. Then I realized that when I installed VS, I unchecked one of the basic features, called "Visual C++ Run-Time Libraries". So I modified the installation to include this feature. Afterwards compilation proceeded successfully and the problem was solved. Is it possible that your installation is missing something that the other person has? If you can get your project to work on this other person's installation, then that might help to pinpoint the problem. Hope this helps. Good luck!

NGNeer
  • 11
  • 1
0

Does a simple hello world program that uses <iostream> compile and run fine?

If so, the Visual Studio system settings are fine and there is something probably wrong in either the project settings or the source.

You can eliminate the source by checking to make sure that the code is actually using #include <iostream> as opposed to #include <iostream.h>. Once that is done, make sure your header search paths point to the right place (the same as the default values in your hello world project for a start)

Carl
  • 43,122
  • 10
  • 80
  • 104