How to solve “Unresolved inclusion: ” in a C++ file in Eclipse CDT?


How to solve “Unresolved inclusion: <iostream>” in a C++ file in Eclipse CDT?



I download eclipse for c++ (cdt-master-8.0.2.zip).



When I write:


#include <iostream>



It marks:


Unresolved inclusion: <iostream>



How can I fix it?





Platform? Do you have gcc installed?
– Dhaivat Pandya
Apr 29 '12 at 16:29





@DhaivatPandya: No, How I install it?
– Adam Sh
Apr 29 '12 at 16:32





See my answer below.
– Dhaivat Pandya
Apr 29 '12 at 16:35




12 Answers
12



Go to Project > Properties > C/C++ General > Preprocessor Includes... > Providers and select "CDT GCC Built-in Compiler Settings".





I cannot believe that this actually worked. Wow, thank you!
– Jake88
Feb 14 '14 at 1:52





I got a Unsolved inclusion from #include <string>. But it worked to me. Thanks!
– Natanael
Feb 23 '14 at 12:14





This worked for me. I still got flaky behaviour similar to Natanael until I deleted the project, re-imported, cleand and re-built.
– Jacko
Jun 21 '14 at 3:24





Nope, doesn't solve the problem. Are there any solutions that actually solve the issue?
– Joehot200
Sep 30 '14 at 8:53





This plus ALSO unchecking the Cross-GCC Built in Compiler Settings did it for me.
– user1205577
Mar 6 '16 at 16:30



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. enter image description here



Make sure that your file has .cpp extension and not .c, I just had this problem





2.5 hours of searching, and finally a solution!
– dberm22
Jan 9 '15 at 19:40



Install gcc.



If you're on linux, use the package manager.



If you're on Windows, use MinGW.





Installing gcc is not always sufficient to resolve the inclusion.
– ehudt
May 1 '13 at 14:44





Solves the problem 99% of the time. Why else would iostream not load, unless there's something terribly wrong with your system? I think that we could say this sort of response for every answer, e.g. if its a syntax error and someone fixes it, the response could be, "it could be the compiler that has a bug". But, the chances of that happening are pretty low.
– Dhaivat Pandya
May 2 '13 at 0:40





@DhaivatPandya: I think he means installing gcc is only one of several required steps. (Unless eclipse can magically detect that gcc was suddenly installed? It might, I don't know)
– Mooing Duck
Jan 31 '14 at 0:58






That makes sense.
– Dhaivat Pandya
Feb 1 '14 at 16:02





Note that I used eclipse for a month working on a project, and suddenly all my #include statements got this warning (gcc obviously installed), so installing gcc is not a real solution.
– GreySage
Nov 17 '15 at 19:10



In my case it was not the CDT GCC Built-in Compiler Settings. On by including CDT GCC Built-in Compiler Settings Cygwin did the parser recognized my #include <iostream>.


#include <iostream>



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:



C:MinGWlibgccmingw324.8.1includec++



You can add the path in Eclipse under:
Project > C/C++ General > Paths and Symbols > Includes > Add. I hope that helps





It does help me.
– Rodolfo
Jul 2 '16 at 15:30



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.



http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.cdt.doc.user/concepts/cdt_c_before_you_begin.htm



I'm using Eclipse with Cygwin and this worked for me:



Go to Project > Properties > C/C++ General > Preprocessor Includes... > Providers
and select "CDT GCC Built-in Compiler Settings Cygwin [Shared]".



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.



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:


sudo apt-get install g++



I am running eclipse with cygwin in Windows.



Project > Properties > C/C++ General > Preprocessor Includes... > Providers
and selecting "CDT GCC Built-in Compiler settings Cygwin" in providers list solved problem for me.



On Windows, with Eclipse CDT Oxygen, none of the solutions described here worked for me. I described what works for me in this other question: Eclipse CDT: Unresolved inclusion of stl header.



Also set "Command to get compiler specs" ${COMMAND} on Linux


${COMMAND}



First do:



and then under: "Command to get compiler specs" replace:


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



with:


g++ -std=c++11 -E -P -v -dD "${INPUTS}"



Otherwise, it fails with:


Unable to find compiler command in toolchain=cdt.managedbuild.toolchain.gnu.base



Tested on Eclipse Photon Release Candidate 3 (4.8.0RC3), Ubuntu 16.04, and this minimal Makefile project with existing sources.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV