How to solve Unresolved inclusion: <iostream> in eclipse?

扶醉桌前 提交于 2020-01-13 12:07:12

问题


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?


回答1:


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




回答2:


I've searched for a few hours and tried a lot solutions.

Envirment: windows, Eclipse IDE for C/C++ Developers

Version: Kepler Service Release 2

CDT: 8.3.0

Following steps works for me:

  1. make sure the envirement is clear. => I suggest delete the eclipse and unzip it again from your orginal download.

  2. make sure the workspace is clear. => Delete .metadata folder in your workspace folder.

  3. use valid MinGW. => the one using download tool is slow and I'm not sure which one to select. I suggest download MinGWStudio from http://vaultec.mbnet.fi/mingwstudio.php This is a IDE tool like eclipse contains a downloaded unzip MinGW. Make sure you download the one plus MinGW compiler which is about 20M. You can use this studio if you want or copy the MinGW folder to C:/ if you still prefer eclipse. Copy /MinGW inside /MinGWStudio to C:/.

  4. close your eclipse and reopen it, create a new project, you should able to see MinGW section for new project option, and it will auto map g++, gcc and include files under C:/MinGW folder. Just make sure you copy MinGW folder from MinGWStudio to the root of C:/.

You will able to see your include after these steps.

includes_screen_cast




回答3:


right click your project click properties goto C/C++ Build > settings click on Misc. under GCC C++ Compiler and the other flags code should have this after it -std=c++11 then go to Misc. under GCC C Compiler and add this to the other flags code -std=gnu11 apply save your project build your project and it should work



来源:https://stackoverflow.com/questions/23172350/how-to-solve-unresolved-inclusion-iostream-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!