Bug 7549

Summary: Eclipse indicates several problems with a project that builds fine
Product: [Yocto Project Subprojects] Eclipse Plugin Reporter: Joshua Lock <joshuagloe>
Component: eclipse-pluginAssignee: Jose Lamego <jose.a.lamego>
Status: VERIFIED WONTFIX QA Contact: Valentin Hangan <valentinx.hangan>
Severity: normal    
Priority: Medium CC: anibal.limon, bluelightning, bogdanx.a.voiculescu, ioanax.grigoropol, todor.minchev, yp.ep.watcher, yp.watcher
Version: 1.7.1   
Target Milestone: 1.9 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)
Bug Depends on:    
Bug Blocks: 8261    
Attachments:
Description Flags
Screenshot of a Gtk+ Hello World which builds fine but shows problems in the IDE none

Description Joshua Lock 2015-03-31 13:17:44 UTC
I'm trying to test the Eclipse plugin with Dizzy by using the skeletal projects provided by the Yocto Eclipse Plugin.

When I use the Gtk+ hello world project template I'm able to successfully build and deploy the binary however Eclipse tells me there are 16 problems with the project which are all semantic errors about unresolveable symbols and types, most of which are provided by Gtk+.

I've tried working around by rebuilding the index (Right-click on project in Project Explorer -> Index -> Rebuild).

ADT Plug-in: 1.4.0 (installed from the 1.7.1/kepler software installation site)
Eclipse IDE: Kepler SR 2 (installed from a tarball downloaded from eclipse.org)
Poky: Dizzy HEAD (running the dizzy branch from git with a HEAD of ec75238f6cc2d2d8d40e0268f6d2acc070cbe9a4)
Toolchain: bitbake -c populate_sdk core-image-sato-sdk
OS: Ubuntu 14.10 x86_64
Comment 1 Todor Minchev 2015-04-23 08:27:34 UTC
This sounds like an upstream issue. Could you please attach a screenshot?
Comment 2 Joshua Lock 2015-04-23 16:56:32 UTC
Created attachment 2485 [details]
Screenshot of a Gtk+ Hello World which builds fine but shows problems in the IDE

Attached a screenshot showing the problem. The project is one of the plugin provided samples Yocto Project ADT Autotools Project / Hello World GTK C Autotools Project.
Comment 3 Jose Lamego 2015-08-17 15:39:26 UTC
The cause for the reported error messages is that Eclipse is not searching for includes recursively through the provided path in Autotools-related projects, even when the includes are listed, therefore the "unresolved" issues. The project can compile because Makefile does appropriately deal with dependencies.

A simple workaround is to create a new linked folder pointing to the include folder ("/usr/include" works although headers should be picked up from the sysroot, not the local host) and to all folders containing any other include file marked as unresolved.

This workaround will be included in the documentation until an automated fix is implemented. This new task must be linked to this bug when assigned.
Comment 4 Jose Lamego 2015-08-17 15:41:19 UTC
Workaround steps are: 

Right-click Project > New > Folder > Advanced > Link to alternate 
location (linked folder) > Browse to /usr/include > Ok > Finish
Comment 5 Joshua Lock 2015-08-18 10:35:36 UTC
I'm not sure why this was assigned to me? It would be useful to add a comment when doing that.

So far as I can tell Jose has identified a short term workaround (which needs documenting) and plans to create a new ticket to handle fixing the underlying issue.

As for the workaround; Jose - you appear to be recommending the user add the include directory from their host system? I don't think that's the right thing to do, not least of all because the SDK may include headers that aren't available on the host. In which case the issue will persist.

Or am I misunderstanding?
Comment 6 Paul Eggleton 2015-08-18 10:39:38 UTC
Changing this out of NEEDINFO since it's not clear that any info is needed.
Comment 7 Jose Lamego 2015-08-18 14:15:51 UTC
Joshua: You shouldn't be assigned, sorry about that. You are right, headers should be picked up from the sysroot, not the host system. This temporary workaround is only recommended when working with a GTK, Yocto Project ADT Autotools project to deal with the GTK-related unresolved includes and only until an automated fix is developed.
Even more interestingly, looks like it is also needed to add the /usr/include directory to Project Properties > C/C++General > Paths and Symbols > Includes > Languages, along with the linked folder.
Comment 8 Jose Lamego 2015-09-04 22:47:17 UTC
Further investigation showed that the reported behavior (caused by a failed recursive parsing of the include folders in Eclipse CDT) is a known error present only in certain specific machine/project configurations, for which currently there is no fix other than manually linking the folders to the project. Some examples in [1] to [4].

The bug 8261 was submitted to add a note to the Yocto Development Manual in the appropriate section on how to manually link the include folders to a Yocto project ADT Autotools. A link to this bug was included for reference.

The proposed text for the note to be included is:

4.2.2.4.1 Note for Yocto Project ADT Autotools projects
"When building "Yocto Project ADT Autotools" projects, the Eclipse IDE may display some error messages for Functions/Symbols/Types that cannot be "resolved", even when the related include file may be listed at the project navigator and even when the project is able to build. 
For these cases only, it is recommended to add a new linked folder to the appropriate sysroot:
 - Select the project
 - Navigate to menu File > New > Folder
In the New Folder Dialog:
 - Select "Link to alternate location (linked folder)"
 - Click Browse to navigate to the include folder inside the same sysroot location selected in the Yocto Project configuration preferences and click OK
 - Click Finish to save the linked folder"

[1] http://stackoverflow.com/questions/12194103/eclipse-cdt-indexer-how-to-solve-unresolved-includes
[2] https://www.eclipse.org/forums/index.php/t/50622/
[3] http://stackoverflow.com/questions/17900370/eclipse-kepler-cdt-include-external-header-files-add-external-include-path-rec
[4] https://www.eclipse.org/forums/index.php/m/1059441/
Comment 9 Valentin Hangan 2015-09-14 05:47:17 UTC
Verified