我正在尝试在Linux中制作一些东西,但它抱怨它无法找到iostream.h。我需要安装什么来获取此文件?
答案 0 :(得分:11)
此标准标题的正确名称仅为iostream
,没有扩展名。
如果您的编译器仍然无法找到它,请尝试以下操作:
find /usr/include -name iostream -type f -print
...并按照编译器的文档将其添加到include路径中。
答案 1 :(得分:10)
标题< iostream.h>是一个过时的标题,从C ++开始标准化为ISO C ++ 1998之前(它来自C ++ Annotated Reference Manual)。标准C ++标头是< iostream>。两者之间存在一些细微差别,最大的区别在于< iostream>将包含的内容放在命名空间std中,因此你必须使用“std ::”限定cin,cout,endl,istream等。有点像黑客(它是一个黑客,因为头文件永远不应该包含“使用”指令,因为它们完全打败了命名空间的目的),你可以定义“iostream.h”如下:
#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
虽然这与原来过时的标题不完全相同,但是对于大多数用途来说这应该足够接近(即,你应该没有任何东西或很少的东西需要修复)。
答案 2 :(得分:2)
我需要在debian上编译partport并遇到问题(centos 4.5工作正常) 我这样做没有成功 ln -s /usr/include/c++/4.5/iostream / usr / include / c ++ / 4.5 / iostream.h
我发现iostream.h是从c ++提供的,我在centos 4.5上找到它
所以我从centos 4.5复制到ubuntu natty文件iostream.h并且它工作了 scp root@ip.centos-4.5:/ usr / include / c ++ / 3.3.4 / backward / iostream.h / usr / include / c ++ / 4.5 / iostream.h