Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse shows unresolved inclusion but it compiles
Eclipse shows unresolved inclusion but it compiles [message #738539] Sun, 16 October 2011 11:16 Go to next message
MrT is currently offline MrTFriend
Messages: 5
Registered: October 2011
Junior Member
I've installed the Eclipse Indigo version on ubuntu. It compiles, and can be run but eclipse show errors, like unresolved inclusion in all the invocations to functions of the standard library like cout, string, etc.
Re: Eclipse shows unresolved inclusion but it compiles [message #738675 is a reply to message #738539] Sun, 16 October 2011 15:38 Go to previous messageGo to next message
Eclipse UserFriend
"MrT" wrote in message news:j7edms$1ai$1@news.eclipse.org...

> I've installed the Eclipse Indigo version on ubuntu. It compiles, and can
> be run
> but eclipse show errors, like unresolved inclusion in all the invocations
> to functions
> of the standard library like cout, string, etc.

Try right-clicking on your project and selecting Index->Rebuild from the
menu.

--
Regards,

Jarrick
Re: Eclipse shows unresolved inclusion but it compiles [message #756496 is a reply to message #738675] Mon, 14 November 2011 03:14 Go to previous messageGo to next message
ds912 is currently offline ds912Friend
Messages: 1
Registered: November 2011
Junior Member
I am have the same problem. Installed Indigo on Fedora 16 in linux.
Created a new project from the simple "Hello World" cpp.
Notice the unresolved iostream error. Tried all the following: language mappng to C/C++, paths and symbols. Nothing worked.
Went to search for the iostream.h header file in
all the possible include folders/directories (ie /usr, etc)and couldn't find it. Did I missed
somthing in the installation?

I am a newbie. Someone jump in please.
Re: Eclipse shows unresolved inclusion but it compiles [message #756615 is a reply to message #756496] Mon, 14 November 2011 14:16 Go to previous messageGo to next message
MrT is currently offline MrTFriend
Messages: 5
Registered: October 2011
Junior Member
Sorry, but I couldn't fix it yet.

The problem is with the eclipse indigo, if you get an older version it will work as it should.

[Updated on: Mon, 14 November 2011 14:18]

Report message to a moderator

Re: Eclipse shows unresolved inclusion but it compiles [message #756646 is a reply to message #756615] Mon, 14 November 2011 15:07 Go to previous messageGo to next message
MrT is currently offline MrTFriend
Messages: 5
Registered: October 2011
Junior Member
More information, I try to compile the default Hello World:

The console view of eclipse says:

index.php/fa/6136/0/

But the Problems View says:

index.php/fa/6135/0/

I can ejecute the application but eclipse continue displaying errors.
  • Attachment: img3.jpg
    (Size: 140.78KB, Downloaded 93620 times)
  • Attachment: img2.jpg
    (Size: 132.50KB, Downloaded 92398 times)

[Updated on: Mon, 14 November 2011 15:16]

Report message to a moderator

Re: Eclipse shows unresolved inclusion but it compiles [message #756731 is a reply to message #738539] Mon, 14 November 2011 20:40 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
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


Re: Eclipse shows unresolved inclusion but it compiles [message #756760 is a reply to message #756731] Mon, 14 November 2011 23:35 Go to previous messageGo to next message
MrT is currently offline MrTFriend
Messages: 5
Registered: October 2011
Junior Member
Thank you very much for your time, that solved part of the problem.

I have added the following path:

/usr/include/c++/4.6.1

In there, it is listed the file iostream so the yellow adviced dissapeared but the red errors continue.

I've noticed there is some kind of indexer, so I asked it to tell me the unresolved inclusions. It says that it couldn't find a file that should be inside bits, that is a folder inside the path.

I search for that folder and the "c++config.h" file that string needs to work is missing. That isn't an eclipse error.

Perharps I'm including an incorrect folder.

There is also a 4.6 version of c++ but it also hasn't the missing file.

index.php/fa/6138/0/

By the way, can I know which is the path that the compiler is using to find the standard library? Because apparently there is no missing file for the compiler or perhaps I have to another forum.

And finally why I have to help eclipse find the path if there are other versions that can manage it correctly. It might be missing some system variable initializacion?
  • Attachment: img4.jpg
    (Size: 111.98KB, Downloaded 90962 times)
Re: Eclipse shows unresolved inclusion but it compiles [message #756765 is a reply to message #756760] Tue, 15 November 2011 00:01 Go to previous messageGo to next message
MrT is currently offline MrTFriend
Messages: 5
Registered: October 2011
Junior Member
I've started adding includes but new ones appears, the worst thing is that sometimes there are repeated files in the filesystem so I don't know which would be the correct one.

For example:

time.h
Re: Eclipse shows unresolved inclusion but it compiles [message #756792 is a reply to message #756765] Tue, 15 November 2011 06:08 Go to previous messageGo to next message
cerh Mising name is currently offline cerh Mising nameFriend
Messages: 6
Registered: November 2011
Junior Member
lun 14 de nov

www.eclipse.org/forums/index.php/t/261852/

I think the parser cannot recognize the output of command gcc -E -P -v -dD ${plugin_state_location}/specs.cpp(spec.c) with other locales other than 'C'
For example: ru_RU.UTF-8
порядок поиска для #include "...": <--- the 'include' at end
порядок поиска для #include <...>:       <---  the 'include' at end
 /usr/include/c++/4.6
 /usr/include/c++/4.6/x86_64-linux-gnu/.
 /usr/include/c++/4.6/backward

and locale 'C':
#include "..." search starts here: <--- the 'include' at  first
#include <...> search starts here:       <----  the 'include' at first    
 /usr/include/c++/4.6
 /usr/include/c++/4.6/x86_64-linux-gnu/.
 /usr/include/c++/4.6/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include
 /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
Re: Eclipse shows unresolved inclusion but it compiles [message #756851 is a reply to message #756792] Tue, 15 November 2011 10:56 Go to previous messageGo to next message
cerh Mising name is currently offline cerh Mising nameFriend
Messages: 6
Registered: November 2011
Junior Member
I was right.
See source plugin org.eclipse.cdt.make.core
org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileSIPConsoleParser.java

...
if(line.startsWith("#include \"...\"") && line.endsWith("search starts here:"))

  expectingIncludes = 1;

else

if(line.startsWith("#include <...>") && line.endsWith("search starts here:"))

  expectingIncludes = 2;

else

if(line.startsWith("End of search list."))

  expectingIncludes = 0;

else

if(expectingIncludes == 1)
{

   if(!quoteIncludes.contains(line))

      quoteIncludes.add(line);

} else

if(expectingIncludes == 2 && !includes.contains(line))

   includes.add(line);
...
Re: Eclipse shows unresolved inclusion but it compiles [message #759943 is a reply to message #738539] Wed, 30 November 2011 16:08 Go to previous messageGo to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
Okay, I was having the same problem, and something weird happened. What
I did was the following:

- I manually created a file using g++ as specified in the Discovery
Options dialog, that is, I called "g++ -E -P -v -dD
${plugin_state_location}/specs.cpp >& ~/buildResult" (obviously with the
right value for ${plugin_state_location})
- I then specified the buildResult file as input for "Load build output
from file" in the Discovery Options dialog
- rebuilt the index

It works. So far so good. Now, the weird thing is that putting back
everything as it was doesn't break it. It still works. And it also seems
to take the include from my makefile, and put it in as a built in value,
which is neither intended nor desired.

Anyway, it seems to work. I thought it might be interesting to know


On 10/16/2011 01:16 PM, MrT wrote:
> I've installed the Eclipse Indigo version on ubuntu. It compiles, and
> can be run but eclipse show errors, like unresolved inclusion in all the
> invocations to functions of the standard library like cout, string, etc.
Re: Eclipse shows unresolved inclusion but it compiles [message #759964 is a reply to message #759943] Wed, 30 November 2011 18:09 Go to previous messageGo to next message
Klaus km is currently offline Klaus kmFriend
Messages: 142
Registered: November 2011
Senior Member
Andrea wrote on Wed, 30 November 2011 11:08

Now, the weird thing is that putting back
everything as it was doesn't break it. It still works.


this is not weird, this is, because Eclipse internally stores the paths from older build. In new CDT version you could "Clear" this cache memory:

http://wiki.eclipse.org/CDT/User/NewIn80#Scanner_Discovery

Klaus


Re: Eclipse shows unresolved inclusion but it compiles [message #760218 is a reply to message #759964] Thu, 01 December 2011 15:58 Go to previous messageGo to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
Ah, I see thanks. I also see from the bug report that better solutions
are being discussed, which would be nice.
Ok, now I have a couple of solutions to go on with my code :-) Thanks


On 11/30/2011 07:09 PM, Klaus wrote:
>
> this is not weird, this is, because Eclipse internally stores the paths
> from older build. In new CDT version you could "Clear" this cache memory:
>
> http://wiki.eclipse.org/CDT/User/NewIn80#Scanner_Discovery
>
> Klaus
Re: Eclipse shows unresolved inclusion but it compiles [message #762696 is a reply to message #756731] Thu, 08 December 2011 14:19 Go to previous messageGo to next message
Daniel U. Thibault is currently offline Daniel U. ThibaultFriend
Messages: 6
Registered: July 2009
Junior Member
Klaus wrote on Mon, 14 November 2011 15:40

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


No such entry: under Project -> Properties -> C/C++ Build -> Settings, there is only two tabs: Binary Parsers and Error Parsers. Using Indigo 3.7.1 CDT+IC.
Re: Eclipse shows unresolved inclusion but it compiles [message #762709 is a reply to message #762696] Thu, 08 December 2011 14:33 Go to previous messageGo to next message
Daniel U. Thibault is currently offline Daniel U. ThibaultFriend
Messages: 6
Registered: July 2009
Junior Member
I'm having a similar problem with include files and an apparent disconnect between Eclipse's build process and its error reporting. I'll give detailed steps to reproducing this problem, so we can narrow the causes down as quickly as possible. One thing is for sure: this is not a locale problem.

Eclipse 3.7.1 (Indigo SR1) for C/C++ Linux Developers, Ubuntu 10.10 64-bits

It all started when I imported an existing project that "makes" just fine on its own: I thought Eclipse would help considerably in navigating the files and figuring out what does what. However, some of the #included system headers seemed not to be having the correct effect in Eclipse's view. This was very puzzling, and in the course of investigating this, I managed to recreate the problem in a tiny sand box.

Step one: Create a new C project (File: New: C Project) using the Hello World ANSI C Project sample. The parameters are Executable: Hello World ANSI C Project/Linux GCC, the remaining Empty projects set to Linux GCC, and GNU Autotools set to Hello World ANSI C Autotools Project. Call it "hello". Be sure to generate the makefile automatically (Advanced Settings, I believe it is the default).

Step two: Adjust the include path. Using Project: Properties: C/C++ General: Paths and Symbols: Includes: GNU C, set the search path to /usr/local/include, /usr/lib/gcc/x86_64-linux-gnu/4.4.5/include, /usr/include. The second path depends on the exact version of gcc you have installed. This doesn't matter too much, as long as the build path includes at least /usr/include.

Now if you open hello.c, it looks very simple, and Eclipse is quite happy except for return EXIT_SUCCESS;, which cannot resolve EXIT_SUCCESS. Replace EXIT_SUCCESS with a zero (0) and Eclipse gives the all-clear. Select ]Project: Build Project to generate the executable.

Open a command-line window and drill down to your Eclipse workspace folder's hello/Debug subfolder. Once there, you can run the executable with the line ./hello.

Now the fun begins. Modify hello.c to read in its latter part:
#include <fcntl.h>
int main(void) {
    printf("Hello World!\n");

    int zz = SPLICE_F_MOVE;
    printf("zz (SPLICE_F_MOVE) is '%d'\n", zz);

    printf("Bye World!\n");
    return 0;
}

You'll get an error on the int zz... line: "Symbol 'SPLICE_F_MOVE' could not be resolved". If you Build the project, you'll get a similar error in the console view: "error: 'SPLICE_F_MOVE' undeclared".

Now if you change the preamble to:
#define __USE_GNU
#include <fcntl.h>

You still get the error on the int zz line (in the editor), but the project will Build correctly! You can confirm this by running the binary in the command-line window you opened earlier. This is really odd since examination of /usr/include/fcntl.h will show that it #includes <bits/fcntl.h>, and that latter header #defines SPLICE_F_MOVE (and a bunch of others) in a block guarded by #ifdef __USE_GNU. Why on Earth isn't our #define __USE_GNU properly propagated in the workspace perspective?

So this is my problem in a nutshell: why is it the editor (and all of Eclipse CDT) reports an error (apparently by refusing to process correctly an include), but that the underlying build succeeds?
Re: Eclipse shows unresolved inclusion but it compiles [message #762747 is a reply to message #762709] Thu, 08 December 2011 15:18 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
The editor uses an index of all the files referenced by your project (includes and source) so that it can highlight errors and provide code assist. Building the index can be an expensive operation, so it isn't completely rebuilt each time a file is saved or even when the project is built. My guess is that adding the #define __USE_GNU isn't triggering the needed re-index of the bits/fcntl.h file. You may have to rebuild the index manually in this case. Right click on the project select Index->Rebuild to see if that clears up the errors in the editor.
Re: Eclipse shows unresolved inclusion but it compiles [message #762768 is a reply to message #756760] Thu, 08 December 2011 15:47 Go to previous messageGo to next message
Daniel U. Thibault is currently offline Daniel U. ThibaultFriend
Messages: 6
Registered: July 2009
Junior Member
MrT wrote on Mon, 14 November 2011 18:35

By the way, can I know which is the path that the compiler is using to find the standard library? Because apparently there is no missing file for the compiler or perhaps I have to another forum.


Long answer: see //stackoverflow.com/questions/344317/where-does-gcc-look-for-c-and-c-header-files

Short answer: for C++, type:
`gcc -print-prog-name=cc1plus` -v

for C, type:
`gcc -print-prog-name=cc1` -v

In both cases, hit Ctrl-C to recover your command line prompt after the request is completed.
Re: Eclipse shows unresolved inclusion but it compiles [message #762777 is a reply to message #762747] Thu, 08 December 2011 16:01 Go to previous messageGo to next message
Daniel U. Thibault is currently offline Daniel U. ThibaultFriend
Messages: 6
Registered: July 2009
Junior Member
dpwegener wrote on Thu, 08 December 2011 10:18
The editor uses an index of all the files referenced by your project (includes and source) so that it can highlight errors and provide code assist. Building the index can be an expensive operation, so it isn't completely rebuilt each time a file is saved or even when the project is built. My guess is that adding the #define __USE_GNU isn't triggering the needed re-index of the bits/fcntl.h file. You may have to rebuild the index manually in this case. Right click on the project select Index->Rebuild to see if that clears up the errors in the editor.


Good move to know about, and helpful in some cases, but unfortunately not with the hello test case. Eclipse still reports the SPLICE_* symbols as unresolved while simultaneously building correctly. Note that there are no unresolved includes: the problem is tied to the file's #defines not being carried/propagated into the included files to resolve their contents.

Have you managed to reproduce the problem?
Re: Eclipse shows unresolved inclusion but it compiles [message #762835 is a reply to message #762777] Thu, 08 December 2011 17:24 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
Thinking about it, the behavior you are seeing makes some sense. In order for the editor to see the SPLICE_* declaration, it would essentially have to perform an index of all the include files in the file being edited. Each file would then have to have its own index because a.cpp might have the #define but b.cpp might not. If both files include fcntl.h, they would need separate indexes one for a.cpp that knew what SPLICE_* meant and one for b.cpp that didn't. Multiply this by several hundred/thousand files in a project and index handling would quickly overwhelm the environment.

The C/C++ Build properties provide a section that allow you to define variables to be used for the entire project which are then passed to the build. If the __USE_GNU setting pertains to your entire project, you should probably set the variable there. I'm would expect that the indexer uses these project define settings when building the index. That might fix the problem you are seeing.
Re: Eclipse shows unresolved inclusion but it compiles [message #763144 is a reply to message #762835] Fri, 09 December 2011 08:53 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
This has been fixed in HEAD.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=197989


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Eclipse shows unresolved inclusion but it compiles [message #763426 is a reply to message #763144] Fri, 09 December 2011 18:42 Go to previous messageGo to next message
Daniel U. Thibault is currently offline Daniel U. ThibaultFriend
Messages: 6
Registered: July 2009
Junior Member
Axel Mueller wrote on Fri, 09 December 2011 03:53

This has been fixed in HEAD. https //bugs.eclipse.org/bugs/show_bug.cgi?id=197989


Bug 197989 wrote on 11 November 2011 04:32

The fix will be part of the next CDT release in summer 2012 (either 8.1 or
9.0). Before that you can test the change by picking up a nightly build:
https //hudson.eclipse.org/hudson/job/cdt-nightly/

(It actually says 2011, but that is obviously an error)
Re: Eclipse shows unresolved inclusion but it compiles [message #931325 is a reply to message #763426] Wed, 03 October 2012 05:15 Go to previous messageGo to next message
krishna Mising name is currently offline krishna Mising nameFriend
Messages: 16
Registered: July 2009
Junior Member
index.php/fa/11700/0/what a shame. I installed Eclipse Juno and after 3 days, I just cannot get my Eclipse up and running (ATTACHED IMAGE). Do these guys even test, how come there is no documentation on this issue?

[Updated on: Wed, 03 October 2012 05:22]

Report message to a moderator

Re: Eclipse shows unresolved inclusion but it compiles [message #931326 is a reply to message #931325] Wed, 03 October 2012 05:15 Go to previous messageGo to next message
krishna Mising name is currently offline krishna Mising nameFriend
Messages: 16
Registered: July 2009
Junior Member
how do I resolve my cout?
Re: Eclipse shows unresolved inclusion but it compiles [message #931327 is a reply to message #931326] Wed, 03 October 2012 05:16 Go to previous messageGo to next message
krishna Mising name is currently offline krishna Mising nameFriend
Messages: 16
Registered: July 2009
Junior Member
how come it is so hard to find the default gcc includes anywhere in the world?
Re: Eclipse shows unresolved inclusion but it compiles [message #932466 is a reply to message #931327] Thu, 04 October 2012 05:59 Go to previous message
krishna Mising name is currently offline krishna Mising nameFriend
Messages: 16
Registered: July 2009
Junior Member
Figured out Eclipse Juno include issue:Default Eclipse JUNO C++ project GCC (Executable - whats so different about Auto tools?; Linux tool chain - whats wrong with GCC or Cross tool chain?) includes are as follows:

Includes

/usr/include
/usr/include/x86_64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu
/usr/lib/gcc/x86_64-linux-gnu/4.6/include
/usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed
/usr/local/include


#include <iostream>
#include <cstdio>
using namespace std;

int main() {
cout << "Hello World" << endl; // prints Hello World
return 0;
}

Eclipse complains missing, after rebuilding using Indexer: 1. Unresolved inclusion: 2. Unresolved inclusion: 3. Symbol 'std' could not be resolved 4. Symbol 'cout' could not be resolved
After 3 days, wasting time trying all combinations: I see iostream in ./usr/include/c++/4.6/iostream so ADDed /usr/include/c++/4.6 to includes clears 1. and 2. Re indexing shows lot of missing inclusions: Unresolved inclusion: bits/c++config.h unresolved inclusion: stdio.h ... and others $ sudo find . -name stdio.h ./usr/lib/syslinux/com32/include/stdio.h ./usr/include/c++/4.6/tr1/stdio.h ./usr/include/stdio.h ./usr/include/x86_64-linux-gnu/bits/stdio.h SO WHICH ONE SHOULD I INCLUDE and I see /usr/include/stdio.h already included?

I then tried combinations until I found also ADDing these two removed the errors, anyways its a shame these are not documented anywhere /usr/include/c++/4.6/backward /usr/include/c++/4.6/x86_64-linux-gnu
Previous Topic:"Unresolved inclusion" errors after installing MinGW and Mysys
Next Topic:runs with pathing error
Goto Forum:
  


Current Time: Fri Mar 29 07:50:25 GMT 2024

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

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

Back to the top