Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse c++ Type could not be resolved error even though build is successful

Tags:

c++

eclipse

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.

like image 482
Juozas Kontvainis Avatar asked Apr 06 '12 09:04

Juozas Kontvainis


People also ask

What does it mean when something Cannot be resolved to a type?

"cannot be resolved to a type" means that the compiler has decided that, according to the syntax of the language, what it found at this place in the code has to be type, which means either a class, an interface, or a primitive tpye, but cannot find the definition of any type with that name.

How do I exclude files in eclipse?

In Visual Studio, right-click on the file to be excluded from build, choose Properties, Configuration Properties -> General -> Excluded From Build -> Yes -> OK. In Eclipse, right-click on the file to be excluded from build, choose Properties, C/C++ Build -> Excluded from build -> OK.


3 Answers

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.

like image 190
harper Avatar answered Oct 14 '22 16:10

harper


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

like image 21
Juozas Kontvainis Avatar answered Oct 14 '22 17:10

Juozas Kontvainis


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.

like image 40
Leon Rom Avatar answered Oct 14 '22 16:10

Leon Rom