Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse cdt: Includes header file correct, compiles, but highlights source code: "Unresolved inclusion"

I have a project that uses a shared library from another project. In project settings I put the correct include paths and library for the GCC and G++ compiler (-L and -l option). It all compiles well, no problems here. But the source code is not analyzed correctly. My included headerfile (that is located in the other project) is marked as "Unresolved inclusion and everywhere I use something from it, the source is highlighted as well.

#include "myHeader.h"

Any ideas? thanks!

like image 368
tzippy Avatar asked Sep 17 '12 08:09

tzippy


People also ask

HOW include header file in C Eclipse?

Select C/C++ General -> Path and Symbols. Select Includes tab. In Languages list, select 'GNU C' or whatever C compiler tool chain you use. Press 'Add...' button and add the directory for the include files.

What is CDT in Eclipse?

The C/C++ Development Toolkit (CDT) is a set of Eclipse plug-ins that provide C and C++ extensions to the Eclipse workbench. For more information about Eclipse, see Workbench User Guide > Concepts > Workbench. The CDT provides a C/C++ IDE that simplifies many of the same tools that you can use from the command line.


2 Answers

The one that you are missing here (probably) is, telling the indexer where to look for those headers. I normally manage my own Makefile, so I do not know how to make it work for both the eclipse managed makefile and for the Indexer. Probably you will find that the solution below will fix both.

On the solution; right click on the project in the Project explorer ( or resource explorer ), and select Properties. Now under "C/C++ General" > "Paths and Symbols", click on Includes tab and select "GNU C++". Then on the right side, you can add various include paths ( similar to the -I option on gcc/g++ ) by clicking on "Add..." button.

Once you apply and click OK, the indexer will take a while to clear those unresolved object.

like image 120
ϹοδεMεδιϲ Avatar answered Sep 27 '22 21:09

ϹοδεMεδιϲ


A header should be included like this

#include "myHeader.h"

or if it's a standard lib header:

#include <string>

everything else is invalid.

like image 23
Tony The Lion Avatar answered Sep 27 '22 22:09

Tony The Lion