我正在尝试在Linux上创建一个东西,但它抱怨找不到iostream.h。我需要安装什么来获取这个文件?
这个标准头文件的正确名称只是iostream
,没有扩展名。
如果你的编译器仍然找不到它,请尝试以下操作:
find /usr/include -name iostream -type f -print
...并将其添加到您的包含路径中,根据您的编译器文档进行操作。
#include
指令更正为iostream
后,g++
不能编译这个程序,我会感到惊讶的。 - johnsyweb<iostream.h>头文件是一个古老的头文件,它出现在C++被标准化为ISO C++ 1998之前(它来自于C++ Annotated Reference Manual)。标准C++头文件是<iostream>。两者之间存在一些微小的差异,最大的区别是<iostream>将包含的内容放入std名称空间中,因此您必须使用"std::"限定cin、cout、endl、istream等。您可以通过以下方式定义"iostream.h"来进行某种程度上的hack(这是一种hack,因为头文件不应包含"using"指令,因为它们完全破坏了名称空间的目的):
#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
虽然这不完全与原始过时的标题相同,但对于大多数目的来说,这应该足够接近(即你只需要修复很少或没有东西)。
我需要在Debian上编译partport,但遇到了问题(CentOS 4.5则没有问题)。我尝试了以下方法,但均未成功:
ln -s /usr/include/c++/4.5/iostream /usr/include/c++/4.5/iostream.h
scp root@ip.centos-4.5:/usr/include/c++/3.3.4/backward/iostream.h /usr/include/c++/4.5/iostream.h