Linux Eclipse、Ubuntu 中未解决的 <iostream>

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12335420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:17:52  来源:igfitidea点击:

Unresolved <iostream> in Eclipse, Ubuntu

c++linuxeclipsegcceclipse-cdt

提问by David Kaczynski

Yes, it's thisquestion again...

是的,又是这个问题……

Somehow, I cannot get this issue resolved. Believe it or not, I have experience with Eclipse but only for Java development. I have programmed in C++ using vi but not with Eclipse.

不知何故,我无法解决这个问题。信不信由你,我有使用 Eclipse 的经验,但仅限于 Java 开发。我已经使用 vi 用 C++ 编程,但没有使用 Eclipse。

I have installed:

我已经安装:

  • Ubuntu 12.04
  • Eclipse 3.7.2
  • GCC 4.6.3
  • Eclipse CDT 8.0.2
  • Ubuntu 12.04
  • 日食 3.7.2
  • 海湾合作委员会 4.6.3
  • 日食 CDT 8.0.2

I created an empty Makefile project and selected the Linux GNU Toolchain:

我创建了一个空的 Makefile 项目并选择了 Linux GNU 工具链:

empty Makefile project

空的 Makefile 项目

I get the standard Unresolved inclusion <iostream>error, and I have some references to various "include" directories in the project:

我得到标准Unresolved inclusion <iostream>错误,并且我对项目中的各种“包含”目录有一些引用:

<code>Unresolved inclusion <iostream></code>error

<code>未解决的包含 <iostream></code>错误

I did notice that, while my "Paths and Symbols" setting for GNU C contains various paths, the same setting for GNU C++ is empty:

我确实注意到,虽然我的 GNU C 的“路径和符号”设置包含各种路径,但 GNU C++ 的相同设置是空的:

GNU C Paths and Symbols

GNU C 路径和符号

GNU C++ Paths and Symbols

GNU C++ 路径和符号

Also, I have the "GNU Elf Parser" under my C/C++ build settings:

另外,我的 C/C++ 构建设置下有“GNU Elf Parser”:

enter image description here

在此处输入图片说明



What am I doing wrong here?

我在这里做错了什么?

Cheers

干杯



Edit:

编辑:

Here's an updated photo of my a project's build path that is working correctly: Updated build path

这是我的项目构建路径的更新照片,该路径正常工作: Updated build path

采纳答案by Benjamin

The reason is that Eclipse simply cannot import a proper header. C++ iostream header in Ubuntu can be found:

原因是 Eclipse 根本无法导入正确的标头。可以在 Ubuntu 中找到 C++ iostream 头文件:

$: sudo find / -name iostream

/home/beniamin/QtSDK/Madde/toolchains/arm-2009q3-67-arm-none-linux-gnueabi-x86_64-unknown-linux-gnu/arm-2009q3-67/arm-none-linux-gnueabi/include/c++/4.4.1/iostream
/home/beniamin/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/include/c++/4.4/iostream
/usr/share/gccxml-0.9/GCC/2.95/iostream
/usr/include/c++/4.6/iostream
/usr/include/boost/tr1/tr1/iostream

$: sudo find / -name iostream

/home/beniamin/QtSDK/Madde/toolchains/arm-2009q3-67-arm-none-linux-gnueabi-x86_64-unknown-linux-gnu/arm-2009q3-67/arm-none-linux-gnueabi/include/c++/4.4.1/iostream
/home/beniamin/QtSDK/Madde/sysroots/harmattan_sysroot_10.2011.34-1_slim/usr/include/c++/4.4/iostream
/usr/share/gccxml-0.9/GCC/2.95/iostream
/usr/include/c++/4.6/iostream
/usr/include/boost/tr1/tr1/iostream

So basically, I suppose the one you are looking for is /usr/include/c++/4.6/iostream, so you should in some place include this directory.

所以基本上,我想你要找的是/usr/include/c++/4.6/iostream,所以你应该在某个地方包含这个目录。

Edit: You should also have installed g++, or simply install build-essential package, which is obligatory for building debian packages. Nevertheless, g++ should have been included in your Ubuntu installation anyway.

编辑:您还应该安装 g++,或者只是安装 build-essential 包,这是构建 debian 包所必需的。尽管如此,无论如何,g++ 应该已经包含在您的 Ubuntu 安装中。

回答by Snow

Yes, I have found that using

是的,我发现使用

$: sudo find / -name iostream

and adding the includes file in the includes path and then it success.

并在包含路径中添加包含文件,然后它就成功了。