Include directory specification not working on Eclipse Juno - eclipse

I'm using the latest 32bit Eclipse Juno. I've seen many posts about folder inclusion, but none worked for me.
The problem:
#include<iostream>
#include<osgDB/ReadFile>
#include<osgViewer/Viewer>
The compiler (GCC) reports "unresolved inclusion <iostream>" and corresponding unresolved inclusion errors for ReadFile and Viewer.
What I tried, to solve it:
In Project properties > C/C++ General > Paths and symbols > Includes. I added /usr/include/c++/4.4.4/ for all configurations and all languages. This automatically caused the values in C/C++ Build > Settings > GCC C compiler and GCC C++ compiler's includes > include paths to contain the same values.
The unresolved inclusion error persisted.
Then I tried adding iostream to the include files section below the include paths section. Still no use. Even tried closing and re-opening eclipse after the changes. Still no use.
The only other option was to specify the absolute path which worked:
#include "/home/nav/osg/osg/include/osgDB/ReadFile"
#include "/home/nav/osg/osg/include/osgViewer/Viewer"
#include "/usr/include/c++/4.4.4/iostream"
But isn't the right way to do it. Could anyone help with specifying the include paths the correct way?

I had similar problem and it was caused by the indexer not using the correct build configuration. By default, the indexer was set to use global settings, rather than project specific ones (I'm using Nsight, the version of Eclipse by Nvidia).
Go to
Project properties -> General -> Indexer
Tick
Enable project specific settings
Select
Use active build configuration
This might be irrelevant for you. I'm compiling the same project on multiple machines/OS's and hence have different include paths for each build configuration.

Related

Unresolved inclusion eigen3/Eigen/Geometry

I have this problem:
unresolved inclusion:
I am working with Eclipse and I typed :
#include <eigen3/Eigen/Geometry>
I checked Project->Properties and this is what I have is this:
So I think it should be included. What is going on with eclipse?
Look into C/C++ General -> Indexer, and be sure to tick:
Enable project specific settings
Index unused headers as C++ files
This should solve your issue.
Eclipse tries to include by default the .h files of the library but those are not sufficient to build the project correctly. As done by default by Eclipse for the stdlib, substitution rules need to be used in order for Eclipse to automatically handle includes correctly.
Go to Preferences > C/C++ > Coding Style > Organize Includes > Header Substitution, There you can add a new rule, and import the eigen-header-substitution.xml file.
Please reference http://eigen.tuxfamily.org/index.php?title=IDEs.

Eclipse/CDT Type '__uint128_t' could not be resolved

I am working with c++ and it got type __uint128_t in the code. The code compiles fine on g++ (GCC) 4.8.3, but Eclipse/CDT always show error on "__uint128_t". The actual error message is "Type '__uint128_t' could not be resolved".
I tried several things already, including re-index, adding -std=c++11 to compiler's setting. Does anybody know how to make the error message disappear?
I am running Eclipse Luna Release (4.4.0) and CDT 8.4.0.
Eclipse will be able to correctly "parse" this type only if it's defined in some header of your toolchain. If it is a builtin type in compiler (just like "int", "char" and so on) - and I guess it is - then Eclipse would need to have special code to handle that type. So unless someone implements handling of this token in Eclipse, your only option is to disable this particular code analysis check for the files that use this type...
unchecking "Use global provider shared between projects" and adding -std=c++11 to the command line for the compiler specified in the "CDT GCC Built-in Compiler Settings", which can be found by opening project properties and going to "C/C++ General", "Preprocessor Include Paths", "Providers" tab.
then rebuilding the index: right-click the project, "Index", "Rebuild".
for detail please refer to the answer by davmac in post: Type 'uint32_t' could not be resolved
I had similar difficulties with Eclipse Oxygen.3 (with CDT 9.4 on Debian 7.10 64-bit, and GCC 4.7.2). I tried everything mentioned on StackOverflow as of March 30, 2018 to no avail.
Several headers in my project were being included by multiple source files. These headers were protected by #ifdef guards, but Eclipse CDT's CODAN code analysis system didn't seem to permit these guarded headers to apply to more than one .cpp source file. So numerous types and functions which returned those types were not recognized.
But after setting Window > Preferences > C/C++ > Indexer > Index all header variants, and then Rebuilding the index for the project, subsequent code analysis runs succeeded.
See a related answer from me if trying to utilize workspace-level settings.

Unresolved inclusion of Qt in Eclipse

Eclipse fails to locate Qt includes. Likewise, it fails to provide auto-complete functionality for Qt classes.
I did Project -> Properties -> Paths and Symbols -> Includes -> Add to the include directories of Qt in /usr/include/qt4/. This caused Eclipse to recognize certain certain classes such as QString; however, there is no auto-complete.
I have scoured the web to no avail. How do I make Eclipse index Qt into my project?
Edit: 12/20/12
I have solved my own problem. It appears order of the includes matter. I put
'usr/include/qt4'
'usr/include/qt4/Qt'
'usr/include/qt4/QtCore'
'usr/include/qt4/QtGui'
into Project Properties -> C++ General -> Paths & Symbols. I rebuilt and the auto-complete worked.
You need to add several include directories, those listed by e.g. the command
pkg-config --cflags QtGui QtXml QtSvg QtDBus
(and others Qt packages).

eclipse for android c source code - how to resolve compiler head file?

I am now using eclipse to develop driver and daemon on android platform in C code with a pandaboard, and I want to use eclipse plus CDT as an edit and browse tool.
I have imported android-source code into eclipse as a makefile project, and processing with indexer.
My problem is, since there are lots of head files for different archetecture(x86, arm, etc) like etc, etc. Eclipse reports an error like "unresolved inclusion xxx" because there are too much candidates of those files. Can eclipse analysis makefile and select the correct path like compiler if I specify a variable or identifier to notify eclipse just like a makefile option?
Can anyone help me, please?
Thanks,
-Yunfei
For your driver work checkout:
http://wiki.eclipse.org/HowTo_use_the_CDT_to_navigate_Linux_kernel_source
In general when working with a Makefile project you need to give Eclipse a hand so it knows where to find the includes and which preprocessor symbols are defined.
Right click on your project. Select properties -> C/C++ General -> Path and symbols.
Add the most important include paths and the indexer results will become much better.

Eclipse CDT shows semantic errors, but compilation is ok

I have installed Eclipse Indigo for C/C++ Linux developers on Ubuntu 10.04 x86.
When I use common predefined macro __BASE_FILE__ Eclipse says Symbol '__BASE_FILE__' could not be resolved, but compilation is OK. I have to use it so often in my code and Eclipse fills my screen with red lines and bug icons :)
How can I fix this?
Not sure if this addresses your specific problem, but I also had semantic errors. They just came out of the blue after having a working project.
Anyway, I fixed it with a single option in workspace settings by setting:
"Build configuration for indexer: Use active build configuration"
The other option was "Use the build configuration specified in the project's indexer settings" and this is the one that wasn't working. I think it may have been corrupted after an eclipse crash.
Window -> Preferences -> C/C++ -> Code Analysis -> Syntax and Semantic Errors: OFF
This won't solve the cause of the problem but at least will stop the false errors from being shown.
The simplest solution is to reset the indexer:
Window / Preferences / C/C++ / Indexer.
uncheck "Enable indexer" ->>OK
rebuild all, may show lots of errors
check "Enable indexer" ->>OK
rebuild all
This error can be produced by forced closing of eclipse by power failure.
You need to rebuild the index of your project.
Right-click on the project, then Index->Rebuild.
Deleting the .metadata folder , and then Import project .
This way is OK!
Updated:
You have to add proper paths to Project->Propoerties->C/C++ General->Paths and Symbols. If it does not help, you can configure Eclipse Code Analyser (which generates the 'errors') in Project->Properties->C/C++ General->Code Analysis. Under the error description you have problem with, try Customize Selected->Scope->Exclusion Patterns.
IMO the correct solution is to define the symbol in Project -> Properties->C/C++ General -> Paths and Symbols -> Symbols tab. Since you can assume the symbol will always be supplied by the compiler, you just tell Eclipse to consider it defined.
I had the same problem just recently, where Eclipse complained about undefined macro, that i always supply using -D<MACRO_NAME> compiler option.
I think it has something to do with the workspace/.metadata.
I had the problem of semantic errors reported but Hello World compiles and runs.
I deleted the project, created another one, same error reporting. Reinstalled CDT, same thing. Deleted the workspace, shut down Eclipse, restarted, created new hello world, same thing. Deleted the workspace again, shut down Eclipse again, this time noticed that Eclipse had recreated the workspace folder during shutdown when it couldn't find it. Deleted the workspace with Eclipse shut down. Restarted Eclipse, created HW project, errors show for about a second and then gone. Deleted project, created another one, errors show for a sec, then poof.
If you actually had projects in your workspace (mine was a clean install), I bet that you could just delete the .metadata folder within the workspace, and it would fix it.
I personally agree with compostus' answer.
It's good to solve the real problem that eclipse's code analyzer have.
But when I try this steps:
define the symbol in Project -> Properties->C/C++ General -> Paths and Symbols
I don't find symbol tab or any place to add a symbol. what I want to do is putting macros like -DANDROID or #define ANDROID 1 to eclipse so that the code analyzer can find this definition.
I'm under Mac OSX mountain lion.
adding as another answer, hopefully this will help someone.
I have a ~simple workspace (1 c++ shared-object (linux's version of a DLL, 3 c++ executables, and a pydev python project)
I checked out all the code to a new machine, and it builds fine but had numerous 'semantic errors' on std-c and std-C++ code and includes.. I went through all the discovery / indexer setting to no avail.
==> deleting the entire .metadata folder fixed this.
Since i had nothing non-trivial set up in the workspace (all in the project files / makefiles), eclipse happily created a fresh workspace, and i simply had to do a file->import-> existing projects
If on Ubuntu, go to Window > Preferences > In Search box type "Indexer" > Select Indexer in left column.
Under heading "Indexer Options" tick the following options (all but those involving the skipping of files):
Index files source files not included in project
Index unused Headers Index all header variants
Index source and header files openend in editor
Allow heuristic resolution of includes
Under heading "Indexing Strategy" tick both options which are:
Automatically update the index
Update index immediately after every file-save
Under heading "Build Configuration for the indexer" select the following option:
User active build configuration
try this:
Preferences --> c/c++ --> Indexer --> Index all header variants
check this option.
This is a file indexing issue.
Solution - Right click on the project, Index->Freshen all files.
(Applies to Eclipse CDT.Oxygen)
In my case, I eventually discovered that the indexer was having problems because a colleague had “helpfully” duplicated a whole load of declarations in two header files that were only included together in a small subset of C files in the project. Removing the duplications (and making one header include the other) allowed the indexer to function correctly again.
It was particularly a problem with duplicated enumerations, for some reason. I do not know why this is so.
I used #pragma once in my code. This configuration caused me to have the problem:
---fileA.h---
#pragma once
#define MYMACRO(X) func(X)
---fileB.h---
#include "fileA.h"
---fileB.cpp---
#include "fileB.h"
MYMACRO(5) <---- warning here
I replaced #pragma once with #ifndef #define HEADER_FILE_H #endif, and that fixed the problem.
Not sure if this works for the OPs issue, but I had semantic errors in eclipse Luna and was able to resolve them by following instructions in this thread: Eclipse shows unresolved inclusion but it compiles
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
In my situation, eclipse had determined one of my include directories, but did not determine that there were sub-include directories within it.
I had a similar issue but my compile was fine but Eclipse showed errors on lines that used a #define from another include file. I fixed by checking "Index all header variants". I think the classis #ifndef FILENAME in include file was process multiple times in Indexer and so 2nd time the FILENAME was defined so all #defines in .h file were not "seen" by the preprocessor. Go to Window | Preferences | C/C++ | Indexer.
I have the same problem. Compiler preprocesses ok, but static analyzer doesn't. In my source file:
#define PLATFORM_INC_FILES
#include <platform.h>
int coflags=O_BINARY; // Undefined symbol
In platform.h (an OS dependent header to help creating portable code):
#ifdef PLATFORM_INC_FILES
#include <stdio.h>
...
It looks like static analyzer doesn't take the .c #define statements into account when preprocessing included headers. By defining it at the symbols dialog, errors dissapear, but that is a project scope symbol definition, resulting in every source to include every system header in my case.
Hope it gets fixed soon...
Using Eclipse Mars and MinGW on MSIS2.
The problem occurs this way: I insert a new variable name into the code somewhere e.g. "newone" in this example:
int a;
foo()
{
a=17;
newone=23;
}
The file is saved (so the indexer is reindexing).
Then I added the definition:
int a, newone;
foo1()
{
newone=0;
}
foo()
{
a=17;
newone=23;
}
The indexer will still shows the error at the line " newone=23;" but not at the other lines of code containing "newone".
Solution: first define your variables, then use it.
M.
In the past, I would define the ANDROID symbol in:
Project -> Properties->C/C++ General -> Paths and Symbols -> #Symbols tab
However, the latest version of Eclipse no longer has a # Symbols there, or anywhere else.
It seems there is no longer any way of defining symbols in Eclipse.
Eclipse has so many bugs and problems.
I finally gave up and switched to using Gedit and the terminal to compile.