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

Alaa M. picture Alaa M. · Apr 19, 2014 · Viewed 21.5k times · Source

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:

build_settings general

edit:

I downloaded MinGW and now i have this under Settings:

Updated_Settings

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

include

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:

launch_failed

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?

Answer

Bruce Chidester picture Bruce Chidester · Jun 8, 2017

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