2

Just installed the latest Eclipse IDE and am following the included C++ User Guide right from 'Before you begin' section.

The simple application was successfully completed but once I got to the makefile project and the C++ file tutorials, I got the "Unresolved inclusion: <iostream>" error and a bunch of others related to "cout, cin, endl" because of it.

I followed the tutorials exactly as instructed and am not sure why this occurred. I have since corrected it by following this answer, but now want to know why this happens, especially since I am following the official tutorial and do I have to add the C++ include path for every project on Eclipse?

Related Question

BharathYes
  • 787
  • 2
  • 9
  • 25
  • How did you setup your toolchain? – user0042 Sep 13 '17 at 19:30
  • Be aware that Eclipse is a pretty piss-poor C++ IDE. –  Sep 13 '17 at 19:31
  • @Neil I totally disagree. – user0042 Sep 13 '17 at 19:32
  • @user0042 Which one do you think is worse? –  Sep 13 '17 at 19:33
  • @Neil Let's take CodeBlocks for instance. I don't like Visual Studio much either. – user0042 Sep 13 '17 at 19:34
  • @user Probably not the place for this discussion, but I find both of them far superior to Eclipse - CodeBlocks for its much greater speed, VS for its much greater power. –  Sep 13 '17 at 19:36
  • Guys. There has been enough debate on the best IDE. I choose Eclipse to get back into coding because I felt it has more flexibility incase I decide to try Java. – BharathYes Sep 13 '17 at 19:39
  • @user0042 not sure what exactly you mean by tool chain. I downloaded and installed the latest ide from Eclipse two days back. I had installed both MinGW and Cygwin a while back but did update MinGW using its package manager tool and that is what I select as my compiler while creating the project on Eclipse. – BharathYes Sep 13 '17 at 19:43
  • @Bhar If you want to use basically the same IDE for both C++ and Java programming (though that may not be a good idea), check out the JetBrains tools, such as CLion and IDEA. –  Sep 13 '17 at 19:51
  • Fools. You should all use ed. It's the standard editor. As for Eclipse, it should detect mingw. If it needs some help, and it sure sounds like it, add the bin folder (eg: X:\DevApps\Mingw\mingw64\bin) to the system path. (Warning: Assumes Windows OS and a reboot may be required to force the update through everything that's already running) – user4581301 Sep 13 '17 at 19:52
  • @NeilButterworth I had them installed on my old laptop and was using my edu email for the license. But I thought it was unnecessary to get it all again especially I am only starting out and Eclipse being free was a bonus. I did look at few articles on "Eclipse vs NetBeans vs IntelliJ" and most of the differences being mentioned there didn't make any sense to me. They probably would be a concern for a serious developer handling large projects and not for someone following "C++: the complete reference". Will settle on a ide as my experience grows. – BharathYes Sep 13 '17 at 20:03
  • @NeilButterworth But if you do know of a significant advantage for InteliJ IDEA applicable to a beginner do let me know. – BharathYes Sep 13 '17 at 20:04
  • @NeilButterworth: CLion is not open-source, nor is it free to use. – HighCommander4 Sep 13 '17 at 21:57
  • Does Building the project from within Eclipse succeed? If so, the problem might be that the Built-in Compiler Settings provider is disabled (and so Eclipse is not picking up the compiler's built-in include paths). – HighCommander4 Sep 13 '17 at 21:59
  • @HighCommander4 The program builds and executes without much problem. But it shows 12 errors under the Problems tab. [Screencaps](https://imgur.com/a/mYm5y). The full 'Localtion' text in the first error is `Project Properties, C++ Preprocessor Include.../Providers, [CDT Cross GCC Built-in Compiler Settings] options` – BharathYes Sep 14 '17 at 07:17
  • The following steps works for me: https://stackoverflow.com/a/58552865/4348656 – Peng Zup Oct 25 '19 at 06:37

2 Answers2

1

That first error in the screenshot linked in the comments provides a clue to the problem.

If you go to the preference page mentioned in the error's "Location", you'll see that there is a field called "Command to get compiler specs" with the contents something like:

${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"

This is a command that Eclipse tries to run to get your compiler to output its built-in include paths and other similar information.

The fact that you're getting the error Program "-E" not found in PATH suggests that the variables ${COMMAND} and ${FLAGS} are evaluating to empty strings, so that the first actual token in the command (which the shell then tries to interpret as the program name) is -E.

I'm not sure why those variables are evaluating to empty, but you should be able to work around the issue by replacing ${COMMAND} with g++ (presumably g++ is in your PATH).

HighCommander4
  • 50,428
  • 24
  • 122
  • 194
0

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:

make sure the envirement is clear. => I suggest delete the eclipse and unzip it again from your orginal download. Remove all variable relatated to eclipse and MinGW you set to PATH of envirment variables.

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

use valid MinGW. => the one using download tool is slow and I'm not sure which one to select. I suggest download MinGWStudio which contains an unzip MinGW 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:/.

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. Build your project, everything should goes well even there may some warning hint.

enter image description here

Hope it helps.

Peng Zup
  • 1
  • 4