Andrew
Andrew

Reputation: 668

Eclipse shows annotated errors but builds successfully

I am using Eclipse Juno on Ubuntu 13.04 to develop for the raspberry pi. I configured a cross-compiling toolchain following this guide: http://hertaville.com/2012/09/28/development-environment-raspberry-pi-cross-compiler/

I got my hello world program to compile and run correctly on the raspberry pi, but Eclipse annotates all STL includes as errors.

What I've tried:

I'm guessing I'm missing some path in my configuration, but I'm not sure which one. I did do a considerable amount of research on google and I couldn't find any specific solution to this problem.

So the question is, how do I configure Eclipse to see the C++ STL include paths being used by my build command? (arm-linux-gnueabihf-g++)

Update:

I was looking through the include paths I had blindly copy-pasted before, and noticed that one of them was supposed to point to the C++ STL, but didn't go deep enough in the folder structure. I fixed it by changing .../include to .../include/c++/4.7.2 and that fixed the STL not being seen by eclipse.

But now I have a new problem: when I include a file, for example, #include <string>, I can't use the string type; it underlines every instance of string and says Type 'string' could not be resolved. But if I restart Eclipse the errors go away... until I make any changes to the code, which brings the red lines back. And still, the program compiles successfully.

Upvotes: 3

Views: 701

Answers (2)

Andrew
Andrew

Reputation: 668

So it seems that my problem was fixed by simply changing the include path to the C++ STL to something else and then back again.

Steps:

  1. Find the include path to the STL and change it from .../include to .../include/c++/4.7.2
  2. Restart eclipse, you might notice it's partially working now (there was still some strange behavior going on that I mentioned in the question)
  3. Change .../include/c++/4.7.2 back to .../include
  4. Restart Eclipse and now it should be working.

Upvotes: 0

Gauthier Boaglio
Gauthier Boaglio

Reputation: 10262

CDT can be very capricious sometimes. But if your paths where wrong, the program wouldn't run properly, so your compiler knows about STL. I went into this kind of issue while importing some third-party libraries (source files), and switching the order of the includes fixed it. In your case it might be more complicated...

If you can't get rid of this errors, you still could disable some specific errors and turn it into simple warnings but this would be a bit error prone and dangerous:

Project > Properties > C/C++ General > Code Analysis > Use project settings > Switch the errors that are bugging you into warnings

Good luck with that.

Upvotes: 0

Related Questions