如何在 Eclipse CDT 的 C++ 文件中解决“未解析的包含:<iostream>”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10373788/
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
How to solve "Unresolved inclusion: <iostream>" in a C++ file in Eclipse CDT?
提问by Adam Sh
I download eclipse for c++(cdt-master-8.0.2.zip).
我下载了 c++ 的 eclipse(cdt-master-8.0.2.zip)。
When I write:
当我写:
#include <iostream>
It marks:
它标志着:
Unresolved inclusion: <iostream>
How can I fix it?
我该如何解决?
回答by Alan CN
Go to Project > Properties > C/C++ General > Preprocessor Includes... > Providers and select "CDT GCC Built-in Compiler Settings".
转到 Project > Properties > C/C++ General > Preprocessor Includes... > Providers 并选择“ CDT GCC Built-in Compiler Settings”。
回答by Tod
I use Eclipse for cross compiling and I have to add the explicit directories for some of the standard C++ libraries. Right click your project and select Properties. You'll get the dialog shown in the image. Follow the image and use the + icon to explicitly add the paths to your C++ libraries.
我使用 Eclipse 进行交叉编译,并且必须为某些标准 C++ 库添加显式目录。右键单击您的项目并选择属性。您将看到图像中显示的对话框。按照图像并使用 + 图标显式添加 C++ 库的路径。
回答by lyz
Make sure that your file has .cpp extension and not .c, I just had this problem
确保您的文件具有 .cpp 扩展名而不是 .c,我刚刚遇到了这个问题
回答by ChrisHD
I tried all previously mentioned answers, but in my case I had to manually specify the include path of the iostream file. As I use MinGW the path was:
我尝试了所有前面提到的答案,但就我而言,我必须手动指定 iostream 文件的包含路径。当我使用 MinGW 时,路径是:
C:\MinGW\lib\gcc\mingw32\4.8.1\include\c++
C:\MinGW\lib\gcc\mingw32\4.8.1\include\c++
You can add the path in Eclipse under: Project > C/C++ General > Paths and Symbols > Includes > Add. I hope that helps
您可以在 Eclipse 中添加路径:Project > C/C++ General > Paths and Symbols > Includes > Add。我希望有帮助
回答by Dhaivat Pandya
回答by Pedro Gordo
In my case it was not the CDT GCC Built-in Compiler Settings. On by including CDT GCC Built-in Compiler Settings Cygwindid the parser recognized my #include <iostream>
.
就我而言,它不是CDT GCC Built-in Compiler Settings。通过包含CDT GCC 内置编译器设置 Cygwin,解析器是否识别了我的#include <iostream>
.
回答by superm0
I'm using Eclipse with Cygwin and this worked for me:
我将 Eclipse 与 Cygwin 一起使用,这对我有用:
Go to Project > Properties > C/C++ General > Preprocessor Includes... > Providers and select "CDT GCC Built-in Compiler Settings Cygwin [Shared]".
转到 Project > Properties > C/C++ General > Preprocessor Includes... > Providers 并选择“CDT GCC Built-in Compiler Settings Cygwin [Shared]”。
回答by Alex Byrth
For those using a fresh install of Ubuntu, or another Linux distro, make sure your have at least the package "build-essential" before you try to compile Eclipse CDT projects.
对于那些使用全新安装的 Ubuntu 或其他 Linux 发行版的用户,在尝试编译 Eclipse CDT 项目之前,请确保您至少拥有“build-essential”包。
At Terminal, type:
在终端输入:
sudo apt-get install build-essential
It should be enough to compile and run your apps.
它应该足以编译和运行您的应用程序。
Of course, you can also perform full g++ install, using:
当然,您也可以执行完整的 g++ 安装,使用:
sudo apt-get install g++
回答by nukerebel
It sounds like you haven't used this IDE before. Read Eclipse's "Before You Begin" page and follow the instructions to the T. This will make sure that Eclipse, which is only an IDE, is actually linked to a compiler.
听起来您以前从未使用过此 IDE。阅读 Eclipse 的“Before You Begin”页面并按照 T 的说明进行操作。这将确保 Eclipse(只是一个 IDE)实际上链接到编译器。
回答by yadhu
I am running eclipse with cygwin in Windows.
我在 Windows 中使用 cygwin 运行 eclipse。
Project > Properties > C/C++ General > Preprocessor Includes... > Providers and selecting "CDT GCC Built-in Compiler settings Cygwin" in providers list solved problem for me.
Project > Properties > C/C++ General > Preprocessor Includes... > Providers 并在提供者列表中选择“CDT GCC Built-in Compiler settings Cygwin”为我解决了问题。