Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » (Solved) Indexer disagrees with compiler(Eclipse is giving unresolved symbol errors even though it compiles fine)
(Solved) Indexer disagrees with compiler [message #1708494] Thu, 17 September 2015 07:31 Go to next message
Lyle Tafoya is currently offline Lyle TafoyaFriend
Messages: 6
Registered: September 2015
Junior Member
Hello everyone,

I am using Eclipse Mars 4.5.0 with the CDT plugin and have been having a frustrating experience trying to get the indexer to work correctly. I am receiving errors such as the following

Quote:

Symbol 'string' could not be resolved component.h
Json::Value' could not be resolved component.h


Despite the errors, my code compiles fine. Even with all the warning flags turned on, I don't see anything unusual in the console output while compiling. By contrast, I do not experience this same issue while using another IDE such as Netbeans (although I would really prefer to use Eclipse).

Here are the steps detailing how I created my Makefile project with existing code in Eclipse:

(from Project > Properties)
1. C/C++ Build > Builder Settings > Generate Makefiles automatically = true
2. C/C++ Build > Settings > GCC C++ Compiler > Tool Settings > Dialect > Language Standard = ISO C++11
3. Preprocessor Include Paths, Macros etc. > Providers > CDT GCC Built-in Compiler Settings = ${COMMAND} -std=c++0x ${FLAGS} -E -P -v -dD "${INPUTS}"
4. C/C++ General > Indexer > Use active build configuration = true
5. C/C++ General > Indexer > Index source and header files opened in editor = true

I am using a GNU/Linux operating system and have verified that my includes are in the system path.

Here is some select data from the parser log file
Quote:

Include Search Path (option -I):
/usr/include/c++/5.2.0
/usr/include/c++/5.2.0/x86_64-unknown-linux-gnu
/usr/include/c++/5.2.0/backward
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/include
/usr/local/include
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/include-fixed
/usr/include

Unresolved includes (from headers in index):
file:/usr/include/c++/5.2.0/iostream is not indexed
file:/usr/include/c++/5.2.0/vector is not indexed
file:/usr/include/c++/5.2.0/string is not indexed
file:/usr/include/json/json.h is not indexed
file:/home/lyle/Programming/OpenCGE/Engine/component.h is not indexed

Unresolved names:
Attempt to use symbol failed: std in file /home/lyle/Programming/OpenCGE/Engine/entity.h:11
Attempt to use symbol failed: vector in file /home/lyle/Programming/OpenCGE/Engine/entity.h:11
Attempt to use symbol failed: std in file /home/lyle/Programming/OpenCGE/Engine/entity.h:13
Attempt to use symbol failed: string in file /home/lyle/Programming/OpenCGE/Engine/entity.h:13
Attempt to use symbol failed: size_t in file /home/lyle/Programming/OpenCGE/Engine/entity.h:23
Attempt to use symbol failed: Json in file /home/lyle/Programming/OpenCGE/Engine/entity.h:26
Attempt to use symbol failed: Value in file /home/lyle/Programming/OpenCGE/Engine/entity.h:26
Attempt to use symbol failed: size_t in file /home/lyle/Programming/OpenCGE/Engine/entity.h:27
Attempt to use symbol failed: string in file /home/lyle/Programming/OpenCGE/Engine/entity.h:31
Attempt to use symbol failed: string in file /home/lyle/Programming/OpenCGE/Engine/entity.h:32
Attempt to use symbol failed: string in file /home/lyle/Programming/OpenCGE/Engine/entity.h:34
Attempt to use symbol failed: Json in file /home/lyle/Programming/OpenCGE/Engine/entity.h:37
Attempt to use symbol failed: Value in file /home/lyle/Programming/OpenCGE/Engine/entity.h:37

I have verified that the included files are all located in the correct location according to where the parser is looking and that the permissions

Here is a piece of code from the top of entity.h showing the missing libraries being included
#ifndef _ENTITY_H
#define _ENTITY_H

#include <iostream>
#include <vector>
  using std::vector;
#include <string>
  using std::string;
#include <json/json.h>
#include "component.h"


I have verified that the includes are in the expected location according to the parser log and that the permissions are set appropriately. I have tried cleaning, re-indexing, restarting, re-building, re-creating, and all kinds of different combinations of settings and potential fixes I found in other similar issues. So far nothing has worked. How can I get it to index the above files? Why is it not able to parse them even though the compiler can? Should this be filed as a bug report or is there some configuration settings I'm missing?

I have attached the full parser log. Please let me know if there is any additional information I can provide you with to help. Thank you.
  • Attachment: Untitled.log
    (Size: 10.68KB, Downloaded 86 times)

[Updated on: Sun, 20 September 2015 17:07]

Report message to a moderator

Re: Indexer disagrees with compiler [message #1708685 is a reply to message #1708494] Fri, 18 September 2015 17:01 Go to previous messageGo to next message
David VavraFriend
Messages: 778
Registered: October 2012
Senior Member
Take a peek at Project Explorer ==> <project> ==> Includes.

It looks like the files included by entity.h aren't being searched.
Note the mentioning of std and vector.

Are all of the paths present?
/home/lyle/Programming/OpenCGE/Engine should be there.

If not, you will need to either add it manually to the indexer search path Project Properties ==> C/C++ General ==> Preprocessor Paths, Macros, etc.
or examine the discovery options Project Properties ==> C/C++ Builld ==> DIscovery Options to ensure it is enabled by selecting Auto mate discovery of paths and symbols 2) maybe enable Report path detection problems as well. Note that, when selecting automated discovery, a notice appears that it is deprecated. I don't use it myself

Sometimes, for whatever reason, the indexer refuses to examine some include files. In this case and as a last resort, it is necessary to insert definitions that only the indexer can see. You do this by surrounding them with __CDT_PARSER__ preprocessor statements.

#ifdef __CDT_PARSER__
:
:
:
#endif

Needless to say, this could be a nuisance.
You could also try inserting the same includes in the source file that references entity.h someplace before the reference.

[Updated on: Sat, 19 September 2015 13:35]

Report message to a moderator

Re: Indexer disagrees with compiler [message #1708706 is a reply to message #1708685] Sat, 19 September 2015 04:04 Go to previous messageGo to next message
Lyle Tafoya is currently offline Lyle TafoyaFriend
Messages: 6
Registered: September 2015
Junior Member
I don't seem to have any such section: Properties > C/C++ Build > Discovery. Additionally, none of your other suggestions seem to have any effect. I have managed to put together some repro steps in case anyone feels like helping to troubleshoot this issue.

Quote:

Install Eclipse Version: Mars Release (4.5.0) Build id: 20150621-1200
Install GLFW and jsoncpp to a location found in your path (I did this with my oprerating system's package manager)
git clone -b development https://github.com/Lyle-Tafoya/OpenCGE.git
Clean Eclipse install. Clean workspace directory
File > New > Makefile Project with Existing Code
Project Name=OpenCGE, Languages.C=true, Languages.C++=true, Toolchain=Linux GCC
From Project > properties:
C/C++ Build > Builder Settings > Generate Makefiles automatically = true
C/C++ Build > Settings > GCC G++ Compiler > Dialect = ISO C++11 (-std=c++0x)
C/C++ Build > Settings > Tool Settings > GCC C++ Linker > Libraries > Libraries -l > add > glfw
C/C++ Build > Settings > Tool Settings > GCC C++ Linker > Libraries > Libraries -l > add > GLEW
C/C++ Build > Settings > Tool Settings > GCC C++ Linker > Libraries > Libraries -l > add > jsoncpp
C/C++ General > Preprocessor Include Paths, Macros etc. > Providers > CDT GCC BUilt-In Compiler Settings > Use global provider shared between projects = false
C/C++ General > Preprocessor Include Paths, Macros etc. > Providers > CDT GCC BUilt-In Compiler Settings > Command to get compiler specs = ${COMMAND} ${FLAGS} -std=c++0x -E -P -v -dD "${INPUTS}"
C/C++ General > Indexer > Enable project specific settings = true
C/C++ General > Indexer > Index source and header files opened in editor = true
C/C++ General > Indexer > Use active build configuration = true

Project Explorer > Index > Rebuild
Project Explorer > Build Project
Open Engine/system.h

Any options not specified were left at their default values.
Re: Indexer disagrees with compiler [message #1708729 is a reply to message #1708706] Sat, 19 September 2015 13:43 Go to previous messageGo to next message
David VavraFriend
Messages: 778
Registered: October 2012
Senior Member
I don't seem to have any such section: Properties > C/C++ Build > Discovery

Oddly you found C/C++ Build. In my version (Mars), it is listed under C/C++ Build as Discovery Options and is located between Build Variables and Environment making it the second entry. Typing these menu paths is a pain as it's not possible to copy and paste them . I didn't think it necessary to edit the post since Discovery Options is the only C/C++ menu option starting with the word Discovery. Likewise, I didn't think it necessary to fix the missing Project in Project Properties. Apparently it was necessary, though. My apologies. I've corrected it for future readers.

Sorry that none of my suggestions were of any help. I had a couple more depending but it's rude of me to waste your time. Perhaps someone else's suggestions will be of more help.
Re: Indexer disagrees with compiler [message #1708731 is a reply to message #1708729] Sat, 19 September 2015 15:27 Go to previous messageGo to next message
Lyle Tafoya is currently offline Lyle TafoyaFriend
Messages: 6
Registered: September 2015
Junior Member
I have uploaded a screenshot to show that there is no discovery options. Could this be the problem?
Re: Indexer disagrees with compiler [message #1708733 is a reply to message #1708731] Sat, 19 September 2015 16:03 Go to previous messageGo to next message
David VavraFriend
Messages: 778
Registered: October 2012
Senior Member
Interesting. I doubt it. I don't use Discovery myself. It was just one of many possible solutions to your problem. Use of Discovery seems a deprecated feature. Perhaps your installation is more current than mine. There are a huge number of packages associated with CDT. I have no idea which one (or ones) control Discovery or the Indexer.

Odd that supplying explicit declarations and surrounding them with __CDT_PARSER__ failed to index them. If that didn't work then perhaps large sections of code are being ignored by the Indexer.

I have a running issue where the indexer refuses to recognize a member pulled from <random>. I don't know why but was able to circumvent it by telling CDT it's a macro. Something not always easy to do. The other option was to live with the annoying flagged error.

Good luck.
Re: Indexer disagrees with compiler [message #1708735 is a reply to message #1708731] Sat, 19 September 2015 16:17 Go to previous messageGo to next message
Lyle Tafoya is currently offline Lyle TafoyaFriend
Messages: 6
Registered: September 2015
Junior Member
I have discovered more information.

1. Discovery options appear to be located at Window > Preferences > C/C++ > New C/C++ Project Wizard > Makefile Project
Unfortunately no amount of experimenting with these settings appears to have any effect on this issue.
2. If I remove the "Project Explorer > Index > Rebuild" step from my repro listed above, it mostly works. Everything works except for <chrono> classes. I am able to type std:: and get a autocomplete list which shows vector as well as other classes. As soon as I rebuild the index it seems to break even further. I'm not sure if this information is meaningful, but it seems to be pretty consistent.
Re: Indexer disagrees with compiler [message #1708736 is a reply to message #1708735] Sat, 19 September 2015 16:26 Go to previous messageGo to next message
Lyle Tafoya is currently offline Lyle TafoyaFriend
Messages: 6
Registered: September 2015
Junior Member
One more thing:

I found that if I switch to my master branch and rebuild the index there are no errors. If I switch back to development and rebuild the index all the errors come back. Something about my code seems to be causing issues with the parser. However, my code is all syntactically correct. I have successfully compiled it without issues using both clang and g++.

[Updated on: Sat, 19 September 2015 16:27]

Report message to a moderator

Re: Indexer disagrees with compiler [message #1708758 is a reply to message #1708736] Sun, 20 September 2015 12:09 Go to previous message
Lyle Tafoya is currently offline Lyle TafoyaFriend
Messages: 6
Registered: September 2015
Junior Member
I opened a bug report and have been informed that I am suffering from https://bugs.eclipse.org/bugs/show_bug.cgi?id=471621 This should be fixed with the next version of CDT.

[Updated on: Sun, 27 September 2015 16:17]

Report message to a moderator

Previous Topic:Debugging Matlab Mex Files with Eclipse+CDT
Next Topic:"Undifined reference to main" Enable to compile a Hello World
Goto Forum:
  


Current Time: Mon Sep 24 15:10:44 GMT 2018

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

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

Back to the top