Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Unresolved inclusion <iostream> when using cmake.
Unresolved inclusion <iostream> when using cmake. [message #1831261] Sat, 15 August 2020 21:05 Go to next message
not yourconcern is currently offline not yourconcernFriend
Messages: 7
Registered: August 2020
Junior Member
Hello there, running 2020-09 build on windows and when i create the project without cmake everything works fine. However when i use cmake i get the error "Unresolved inclusion <iostream> ". Weirdly enough program still compiles without a problem i saw alot of solutions from 2012-2015 yet none helps in this version. Any ideas?
Re: Unresolved inclusion <iostream> when using cmake. [message #1831281 is a reply to message #1831261] Sun, 16 August 2020 11:32 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The indexer isn't being told where <iostream> can be found.
It needs the content of the compiler builtin include path list.

Read the help file for more info:
https://help.eclipse.org/2020-06/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_general_scanner_discovery.htm&cp%3D10_4_7_0_4_6

The latest stable release of Eclipse is 2020-06.
Perhaps you've uncovered a bug in 2020-09.


Quote:
i saw a lot of solutions from 2012-2015 yet none helps in this version

There really isn't much change in the way the Indexer works between versions.
What have you tried?
Re: Unresolved inclusion <iostream> when using cmake. [message #1831284 is a reply to message #1831281] Sun, 16 August 2020 14:26 Go to previous messageGo to next message
not yourconcern is currently offline not yourconcernFriend
Messages: 7
Registered: August 2020
Junior Member
David Vavra wrote on Sun, 16 August 2020 11:32

There really isn't much change in the way the Indexer works between versions.
What have you tried?


Alot of people pointed a thing called "Preprocessor Include Paths" at Project --> Properties --> C/C++ General. Which no longer exists in the 2020 versions. Seems 2019 had it.

Somebody did this and apparently it worked on their pc (my pc is not natively english either)
Quote:
I expected this kind of bug. The Eclipse internal scanner expects the gcc output to be in english.
To fix this, force the compiler to use english output when building:
Under "Window -> Preferences -> C/C++ -> Build -> Environment", add two new environment variables "LANG" and "LC_ALL" and set them both to "en_US".


Also this

Quote:
- Open Project Properties->C/C++ Build->Environment
- click Select.. and choose LANG
- use empty value for LANG
- repeat above step for LANGUAGE
- repeat above step for LC_ALL but use the value en_GB.UTF-8

Rebuild project and index


Sadly no luck there either.

Quote:
Hello,

please note the ? beside the include <iostream>

The compiler finds the header, but Eclipse not.

You could help Eclipse and set the path to the header files under:

Project -> Properties -> C/C++ Build -> Settings -> Compiler -> Includes


Compiler settings no longer at that place.

even this (https://help.eclipse.org/2020-03/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_proj_paths.htm) is outdated.

Also someone told me to disallow heuristic resolution of includes. That didn't worked either.
Re: Unresolved inclusion <iostream> when using cmake. [message #1831296 is a reply to message #1831284] Mon, 17 August 2020 04:07 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.
is the consolidated dialog for CDT Discovery.
At least it was until recently.

For whatever reason, a new CMake project doesn't provide it.
Yet somehow the Indexer eventually finds the builtins.
index.php/fa/38781/0/
I have no idea how one is supposed to add external libraries.

The compiler settings in
Project -> Properties -> C/C++ Build -> Settings -> Tool Settings tab --> <Compiler> -> Includes
are to allow CDT to generate makefiles.

However, that is CMake's job in a CMake Project so the dialog is omitted.

There are too many configurations to try.
What I do with a CMake project is

  • run CMake externally to create the Makefile
  • then import the project as an existing Makefile project.
When needed, I update the CMake configuration and re-run CMake.
I do the same with Autotools (although I use the Autotools editors to edit the configuration files).

If you don't have some compelling reason to use CMake, I recommend using a C++ Managed Build Project instead.
I notice that it contains

  • a Scanner Configuration Builder
  • and Scanner Configuration Nature is one of its natures.
index.php/fa/38782/0/

I really don't know what they actually do.
You could try adding the Scanner Configuration Nature to your CMake project and see if that helps.







[Updated on: Mon, 17 August 2020 04:10]

Report message to a moderator

Re: Unresolved inclusion <iostream> when using cmake. [message #1831347 is a reply to message #1831296] Mon, 17 August 2020 19:57 Go to previous messageGo to next message
not yourconcern is currently offline not yourconcernFriend
Messages: 7
Registered: August 2020
Junior Member
My only reason for using CMake was making it compatible on every system and every ide, so lets say i use eclipse on windows and kdevelop on linux they both should work instantly when i put them to the other system.

Adding Scanner Configuration Nature gives me the error "Problems encountered while setting project description".
Re: Unresolved inclusion <iostream> when using cmake. [message #1831353 is a reply to message #1831347] Mon, 17 August 2020 21:53 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
But do you really need Eclipse to generate the initial configuration?
You can still use CMake but let CDT think it's a Makefile Project.
Re: Unresolved inclusion <iostream> when using cmake. [message #1831376 is a reply to message #1831353] Tue, 18 August 2020 14:05 Go to previous messageGo to next message
not yourconcern is currently offline not yourconcernFriend
Messages: 7
Registered: August 2020
Junior Member
Pardon me but i didn't really understand that one, how do i do that exactly?
Re: Unresolved inclusion <iostream> when using cmake. [message #1831392 is a reply to message #1831376] Wed, 19 August 2020 02:45 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Import the project as an existing Makefile project.
Run CMake to create the Makefile.
Re: Unresolved inclusion <iostream> when using cmake. [message #1831426 is a reply to message #1831392] Wed, 19 August 2020 14:49 Go to previous messageGo to next message
not yourconcern is currently offline not yourconcernFriend
Messages: 7
Registered: August 2020
Junior Member
Aah i see, what you saying is create the project as a normal "Eclipse C++ Managed Build Project" and then when making the project on another computer cmake will work fine, correct? Or are you saying again make the project with "Eclipse C++ Managed Build Project" but do not complie the project from eclipse itself but rather open cmake gui and compile your project like that.
Re: Unresolved inclusion <iostream> when using cmake. [message #1831446 is a reply to message #1831426] Thu, 20 August 2020 02:46 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
No. A Managed Build creates its own makefile.
But you could use it instead of CMake.

Import the project as an existing Makefile project.
File --> Import --> C/C++ --> Existing Code as Makefile Project
The project directory has to exist somewhere but it can be an empty directory (or even a workspace project directory).
Then add the CMake files, source, etc. as necessary and run CMake to create a Makefile.
You'll have to refresh the project after running CMake or externally modifying the project.

You could have CMake do the build also.
The key is that a Makefile project won't touch the makefile.

Alternately, you could create a Managed Build but turn off the makefile generation.
Project --> Properties --> C/C++ Build --> Generate Makefiles automatically
This effectively converts a Mangaged Build project into a Makefile Project.

Don't try creating a "new" Makefile project.
It doesn't work the way the documentation is written.
It will likely confuse you.


[Updated on: Thu, 20 August 2020 03:02]

Report message to a moderator

Re: Unresolved inclusion <iostream> when using cmake. [message #1831495 is a reply to message #1831446] Thu, 20 August 2020 22:03 Go to previous messageGo to next message
not yourconcern is currently offline not yourconcernFriend
Messages: 7
Registered: August 2020
Junior Member
Roger! Thank you for the detailed explanation.
Re: Unresolved inclusion <iostream> when using cmake. [message #1854915 is a reply to message #1831261] Sun, 18 September 2022 00:18 Go to previous message
juanito perez is currently offline juanito perezFriend
Messages: 6
Registered: July 2021
Junior Member
I just managed to get this right with a clean instance of eclipse (rename/delete ~/.eclipse)
Eclipse Version: 2022-09 (4.25.0)
cmake version 3.24.2

In my case I needed to import a source repo from git. So I did:
1-Clone the repo manually to some folder.
2-New->Makefile Project with existing code-> Select the previous folder, fill the values
Eclipse indexes the source files fine, symbols and headers are correctly resolved.
3-Right click the project top folder->Properties->Project Natures
4-Remove everything and just leave "C Nature" and "C++ Nature"
5-Add "CMake Nature"
6-Eclipse should rebuild the index and still work normally.

So far so good, I will comment if things go south-ways.
Previous Topic:Indexer Problems when using eclipse CDT with Cmake
Next Topic:Rewrite value in register at Peripherals View and Expression View
Goto Forum:
  


Current Time: Fri Apr 19 05:31:03 GMT 2024

Powered by FUDForum. Page generated in 0.02607 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top