如何解决未解决的包含:< iostream>蚀? [英] How to solve Unresolved inclusion: <iostream> in eclipse?

查看:94
本文介绍了如何解决未解决的包含:< iostream>蚀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中构建了一个简单的程序:

  #include< iostream> 

使用命名空间std;
int main()
{
cout<< 测试<<恩德尔
返回0;
}

它在Visual Studio和CodeBlocks中都有效,但是eclipse却很奇怪。它说:



未解决的包含:< iostream>



我在这里阅读:
,现在我在 Settings 下找到了它:





如何我应该继续吗?
也许现在我不需要 #include< iostream> ,因为它现在已包含在项目中了?





我发现 Includes 下。



所以我尝试删除 #include< iostream> ,但是当我尝试运行该程序时,我得到:
启动失败。找不到二进制文件。错误:





谢谢



编辑:



好像我在其他程序中编译(例如CodeBlocks)并创建 exe 文件,然后创建 eclipse 可以运行它。但是它不能构建自己的 exe



为什么?

解决方案

这个答案也没有帮助我。通过以下步骤解决了我的问题:



您可以尝试将源文件从* .c更改为* .cpp。这将引起gcc将文件视为C ++并搜索正确的路径。可能还需要对Makefile进行一些小的修改,例如在OBJ:行上。而不是:



OBJS = YourFile.o



try



OBJS = YourFile.cpp


I built a simple program in eclipse:

#include <iostream>

using namespace std;
int main()
{
    cout << "TEST" << endl;
    return 0;
}

It worked in Visual Studio and CodeBlocks, but eclipse is acting weird. it says:

Unresolved inclusion: <iostream>

I read here: C++ - Unresolved inclusion: <iostream>

and here: Unresolved <iostream> in Eclipse, Ubuntu

and neither of them worked.

Here are screenshots of project properties:

edit:

I downloaded MinGW and now i have this under Settings:

How should i proceed? Maybe now i don't need #include <iostream> because it's now included in the project?

I found iostream under Includes.

So i tried deleting #include <iostream>, but when i try to run the program i get: Launch Failed. Binary not found. error:

Thanks

edit:

Seems like if i compile in some other program (say CodeBlocks) and create the exe file, then eclipse can run it. But it can't build its own exe.

Why?

解决方案

This answer did not help me either. My issue was solved with the following steps:

You might try changing your source files from *.c to *.cpp. This will provoke gcc to think of the files as C++ and search the proper paths. Might need to make small modifications to the Makefile as well, like on the OBJ: line. Instead of:

OBJS = YourFile.o

try

OBJS = YourFile.cpp

这篇关于如何解决未解决的包含:&lt; iostream&gt;蚀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆