I'm trying to make something in Linux, but it complains that it can't find iostream.h. What do I need to install to get this file?
-
3This is a **bug** in the code that you want to use. If possible, you should provide the maintainers of the project with a bug report. – Konrad Rudolph Sep 13 '10 at 06:56
-
1Possible duplicate of [Why can't g++ find iostream.h?](https://stackoverflow.com/questions/13103108/why-cant-g-find-iostream-h) – phuclv Aug 12 '18 at 11:30
3 Answers
The correct name of this standard header is just iostream
without an extension.
If your compiler still cannot find it, try the following:
find /usr/include -name iostream -type f -print
...and add it to your include path, following your compiler's documentation.

- 136,902
- 23
- 188
- 247
-
2g++ and any standard C++ compiler should automatically find the C++ headers without needing their location to be specified; in fact, the C++ standard allows, in theory, for "
" to be resolved in a manner that does not actually involve a file named "iostream" (i.e., the compiler is allowed to map the name to whatever it wants, so long as it provides the necessary standard library classes and functions required). – Michael Aaron Safyan Sep 13 '10 at 06:50 -
1@Michael: Indeed. I'd be surprised if `g++` didn't compile this after fixing the `#include` directive to `iostream`. – johnsyweb Sep 13 '10 at 07:06
The header <iostream.h> is an antiquated header from before C++ became standardized as ISO C++ 1998 (it is from the C++ Annotated Reference Manual). The standard C++ header is <iostream>. There are some minor differences between the two, with the biggest difference being that <iostream> puts the included contents in namespace std, so you have to qualify cin, cout, endl, istream, etc. with "std::". As somewhat of a hack (it is a hack because header files should never contain "using" directives as they completely defeat the purpose of namespaces), you could define "iostream.h" as follows:
#ifndef HEADER_IOSTREAM_H
#define HEADER_IOSTREAM_H
#include <iostream>
using namespace std; // Beware, this completely defeats the whole point of
// having namespaces and could lead to name clashes; on the
// other hand, code that still includes <iostream.h> was
// probably created before namespaces, anyway.
#endif
While this is not exactly identical to the original antiquated header, this should be close enough for most purposes (i.e. there should be either nothing or very few things that you will have to fix).

- 93,612
- 16
- 138
- 200
I needed to compile partport on Debian and had problems (CentOS 4.5 worked fine). I did this without any success:
ln -s /usr/include/c++/4.5/iostream /usr/include/c++/4.5/iostream.h
I discovered that iostream.h was provided from C++, and I found it on CentOS 4.5.
So I copied the file iostream.h from CentOS 4.5 to Ubuntu 11.04 (Natty Narwhal), and it worked:
scp root@ip.centos-4.5:/usr/include/c++/3.3.4/backward/iostream.h /usr/include/c++/4.5/iostream.h

- 30,738
- 21
- 105
- 131

- 39
- 2
-
2You got lucky. Standard headers do not have to be the same between implementations, and copying can introduce immediate or subtle bugs. Moreover, it covers up the fact that you're using a program written in an antique version of C++ that may have other bugs when compiled by a modern compiler. – David Thornley Dec 28 '10 at 22:43
-
What is *"partport"*? Search engines want it to be "passport". – Peter Mortensen Jul 08 '22 at 17:40
-
OK, the OP has left the building: *"Last seen more than 11 years ago"*. But perhaps somebody else can chime in? – Peter Mortensen Jul 08 '22 at 17:41