30

I have mixed C++ / Java project in Eclipse. I've setup a build.mk file and Eclipse builds project successfully when all files in editor are closed. When I open a .h or a .cpp file Eclipse finds a lot of undefined symbols in them. I have references to 3rd party API and all the problems seem to be related to symbols from that API. Strangely, some types are considered defined in Eclipse, and some are considered undefined even though in some cases they are defined in the same .h file.

My colleague is not experiencing any of these problems, but we are clueless where to start solving this problem. We already made sure that our Eclipse include directories are the same. Is there some way to compare eclipse project settings?

Update: .cproject files and .project files and files in .settings directory know differ only by some paths. Did not help to solve my problem though.

Juozas Kontvainis
  • 9,461
  • 6
  • 55
  • 66
  • you could `diff` your colleague's `.project` and `.cproject` against yours, no easy task but sometimes it saved me... Silly question, but.. have you tried `project/clean`ing your project? – michele b Apr 06 '12 at 09:22
  • Yes, I've tried cleaning. Multiple times :( – Juozas Kontvainis Apr 06 '12 at 09:40
  • 2
    Experienced similar problems with internal parser. Could not find a solution. Is it possible that your colleague has those features turned off ("error" highlighting)? – dbrank0 Apr 06 '12 at 18:59

5 Answers5

79

I had the same problem. It could be resolved by flushing the Eclipse indexer.

I used the projects context menu and selected Index->Rebuild and Index->Freshen All Files. The last removed the error messages.

harper
  • 13,345
  • 8
  • 56
  • 105
  • 7
    You are a life saver 8-) [or at least, a sanity saver...] I was on the way to going nuts b/c repeatedly cleaning/rebuilding of the projects and multiple checking on the preferences did not do the trick... – ysap Aug 28 '12 at 18:37
  • 2
    This was so annoying to me. I could actually debug the application, but the errors indicated it wasn't building. Arrrgh. Thank you for this. – Paxton Sanders May 28 '14 at 20:39
  • 1
    This still didn't fix the issue for me. Although stdint.h stdbool.h etc are included, they're all unresolved for me. I've verified that the paths are included in the list in the project properties and build is successful too! Only Eclipse's parser resolution fails. – padfoot Feb 17 '17 at 08:57
  • Worked for me after deleting a project of the same name and importing that project back into my workspace after I'd moved the files to another directory. – Casey Murray Oct 27 '17 at 22:51
5

Turns out I needed to change Code Analysis settings that are on Launching tab, and I simply did not see that tab.

enter image description here

Juozas Kontvainis
  • 9,461
  • 6
  • 55
  • 66
1

I had the same problem. It take place when in included file I'd used

namespace std

without using it in main file or vice versa. Do check using namespace equally.

Leon Rom
  • 537
  • 4
  • 6
0

You can compile and run the source code also by Right Click On Project>Run C/C++ Code Analysis. This will solve your problem.enter image description here

Deepak
  • 1,669
  • 1
  • 18
  • 28
0

I finally figured this out. Flushing the Eclipse Indexer as mentioned in the top voted answer didn't work for me. This is what I had to do:

I went to: Project -> Properties -> C/C++ General -> Paths and Symbols -> Includes

Here I had the path for my include directory, but what I had to do was delete the directory path, and then re-add it making sure to check the box "Add to all configurations". I also checked the box "Add to all languages", but I don't think that is necessary.

After this, you may need to then click on Project -> C/C++ Index -> Rebuild. I didn't need to, but you might. Also, obviously instead of C/C++ in the paths above, it will be Java or whatever language you are dealing with.

Link1600
  • 1
  • 2