I am trying to migrate a custom C++ project which uses Gtkmm3.0 to Eclipse (Oxygen) on Ubuntu 16.04. The project has its own Makefile and builds fine from the terminal within Eclipse. What I have not been able to do so far is tell the indexer about Gtkmm, and I get lots of these (which is very annoying):
When I hover over the little red bugs, it says:
Type 'Cairo::RefPtr<Cairo::Context>' could not be resolved.
I have done a lot of Googling on this and found nothing so far because all answers seem to assume the project's build tools are managed by Eclipse (See this or this, for example). In my case I have a makefile project instead of an executable project and hence some options are not available to me. For example, the first links speaks about configuring the builder:
We have to add all this directories. On Eclipse select the Project->Properties menu option. Select C/C++ Build->Settings property page and GNU C++ Compiler->Directories from the Tool Settings tab. Now we have to add all directories. In my case (Makefile project) only two tabs are available there: Binary Parsers and Error Parsers.
How can I tell the Eclipse indexer I am using Gtkmm3.0?
Found the solution that works for me:
Open a terminal and enter:
pkg-config --cflags gtkmm-3.0
You will see a list of includes directories (starting with -I). These are the directories you want to add in Eclipse so that it can locate the Gtkmm symbols in the editor.
In Eclipse, go to:
Project -> Properties -> C++ General -> Paths and Symbols
In the Includes tab, select GNU C++. You need to add here add the include directories found in step 1. There is no automated way to do this, yo must enter them one by one.
One trick that can save you some time is to edit manually the Eclipse project setting XML file and add the include directories directly in the XML file. By the end, you should have something that looks like this:
That did it for me, hope this helps!
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.
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.
I've downloaded C/C++ libraries from Cygwin, and set the environment variables according to the instructions here, in NetBeans.
I've also gone through this.
Actually I followed the same steps on a different machine and everything worked out fine.
But on my machine the associations aren't made.
for example: #include<stdio.h> says No such file or directory.
Any idea what the problem might be?
The Cygwin package I downloaded is also fine, I downloaded it twice.
If it's complaining about a #include, that's a compile issue, not a linking issue.
What happens if you create a new C/C++ application project and try to build it?
In the Build node of the project properties, is the correct Tool Collection selected? (Cygwin in your case). And the Tools -> Options, on the C/C++ tab, is that tool collection set up correctly?
You should check whether you have a file c:\cygwin\usr\include\stdio.h.
I have a C project that is built using a makefile, Eclipse constantly warns about "Invalid project path: Duplicate path entries", but I cannot figure out what the hell it wants me to do. I would like to disable this warning and continue with my life.
My application compiles and runs fine, with not a single warning except this one. Being a conscientious developer I am keen to fix this problem so I have the warm fuzzies only a clean build can bring.
This worked for me with Eclipse 3.7.2 and CDT 8.0.2:
Open the project properties | C/C++ Build | Discovery Options.
Click the button by Clear discovered entries now:.
Rebuild.
It is seems to be a new feature in CDT 8. I have had this "Invalid project path: Duplicate path entries" problem for years, and this is apparently the newly provided solution.
Before doing this there were duplicate paths under C/C++ General | Paths and Symbols | Includes tab. I could not get rid of these. They only appear when Show built-in values is checked, so they are apparently generated somehow. After doing the above they were replaced with a set that did not have duplicates. The only difference is that the same settings appeared under Assembly, GNU C, and GNU C++. Previously they were different sets. The ones for Assembly were empty, for example.
So far the problem has not returned.
This problem is a real pain to deal with. It doesn't work very well.
This is applicable to Eclipse 3.4.1 / CDT 5.0.1
From what I can tell, when you create a "C/C++ Project" within CDT, it will try to auto-detect your include paths. Great idea, but the implementation is horrid.
If you delete or rename a directory, the old directory is leftover. If you rename the project, the old directory is leftover. When Eclipse can't find that old directory, it gives you that warning.
My solution is turning the automated discovery off entirely and managing my include paths manually. You need this list of include paths for things like ctrl-click (auto-navigate to defines/functions/files/etc) and shading out #define blocks. It builds the index off this list.
Here's what you need to do:
Right click on your project in the project explorer and go to properties.
Go to C/C++ Build -> Discovery Options
Uncheck "Automate discovery of paths and symbols"
Now go to C/C++ General -> Paths and Symbols
You'll see under the Includes tab Assembly, C and C++ languages with corresponding auto-discovered include directories.
Go to all 3 languages and delete everything.
Open your makefile and transcribe your includes into the corresponding language.
A project rename will still cause the indexer to break. ${project_name} and other globals do not seem to work. If you're having trouble, use the "Workspace" button to browse to the directory you want to include, as that seems to always work but entering it manually does NOT.
Hit apply, then OK.
Right click your project, go to index->rebuild
Restart eclipse.
This should fix things forever. Any time something improperly is shaded out due to a #define or #ifdef block, it's because that list of files is outdated. You'll also know that list is outdated if you get "unresolved inclusions" on #include lines.
Doug Schaefer, hopefully Google indexes this, you find your name, and you fix this awful implementation. =)
I found this bug report to help my problem. I had moved some include paths and couldn't get rid of the old paths.
I've seen this problem too, old paths
are never deleted. To manually fix the
file you need to move/delete the
${projectname}.sc file found under
${workspace}/.metadata/.plugins/org.eclipse.cdt.make.core
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206372
Using Eclipse Luna and CDT 8.5
I fixed the issue by
Open the project properties | C/C++ General | Paths and Symbols
Look at the Source Location tab, I had renamed a directory and it was not updated in this list.
Rebuild
Here I just found another way to re-detect the path automatically:
Open "Workspace Settings-> C/C++ -> Build -> Settings -> Discovery"
Find "CDT Build-in Compiler Settings [Shard]"
Click "Clear Entries" and "Reset" button on the right
Rebuild projects and Done
Hope this will help.
Reference:
http://qing.blog.sina.com.cn/1802712302/6b7334ee33004def.html
It seems like a bug in CDT.
If you really want to get rid of it, you should try getting rid of the spaces in the project path; this was suggested in a search result for the error. If that doesn't work, you can try to open the .cproject file -it's where all the CDT settings lie- and check for an actual path with duplicate entries.
You should check if you have manually defined a symbol that eclipse can figure out from your makefile. I have a project that has a manually written makefile and the problem was solved by removing symbols that I had manually added to C/C++ General -> Paths and Symbols -> Symbols.
No needs to remove .metadata guys, just delete all path located in C/C++ General -> Paths and Symbols -> Symbols and replace them on using click buttom but don't give the path manually
Here's a late answer for Eclipse 4.4 (which does not have a Discovery option).
Delete the project's infoPath file. Eclipse or the ADT plugin (not sure which) will recreate it, and populate it with the correct paths.
You can find the project's infoPath file at <Eclipse workspace>/.metadata/.plugins/com.android.ide.eclipse.ndk/<project>.pathInfo.
I think Eclipse or the ADT plugin determines the new paths from two places: (1) the NDK directory set under Eclipse preferences, and (2) paths in Application.mk. All those paths become "Built-in" paths under Eclipse.
Also see How to change built-in C/C++ paths pointing to a deleted android-ndk-r9 installation?