So I am building some Arduino code in eclipse, as described in Your Second Arduino Project, but every time I use an Arduino library, such as Serial
, Eclipse und
Eclipse may or may not be pulling the paths to index from your build setup, depending on the configuration. Most likely, it is not...it's building correctly because your build setup is just fine, and you can probably build by hand.
The CDT indexer (which is the engine for deciding where all those pretty underlines, as well as code completion, F3 declaration jumping, etc comes from) isn't smart enough in a lot of cases to parse out your Makefiles and know where to look for headers and source. You need to tell Eclipse that information manually.
Go to Project Properties -> C/C++ General -> Paths and Symbols.
The amount of work you need to put into this can vary greatly, depending on your environment. If this external library is the only thing giving you headaches, then you probably just need to add the paths for that library and reindex:
Right-click on the project and select Index -> Rebuild
I had include folders in
Project Properties -> C/C++ General -> Paths and Symbols -> Includes
When I removed those, the red underlines went away, i.e. the build and the IDE where in sync.
I had the same problem.
Index -> Rebuild didn't help.
When I added line #include <avr/iom1280.h>
in main.cpp and made Index -> Rebuild underlines dissapeared.
Then I deleted line #include <avr/iom1280.h>
and project still without inderlines.
Replace iom1280.h
with name of your controller. Look at the "avr\include\avr\" folder for available names
The solution below worked for me: Click to your project using right click. Then: Properties -> C/C++ General -> Paths and Symbols -> Symbols -> GNU C++. Almost for sure there are no symbols at all if you have this problem. Add symbol "__cplusplus" with value "201402L" After this: Right click on Project -> Index -> Rebuild You are done.
Eclipse does not work as well with C++ as it does with Java, but it should warn you about issues once you press "Rebuild" in the menu bar.
Try that, and see if it resolves your problem.
For starters, what color is the underline? This makes a difference, as yellow means it's a warning, and red means it's an error (critical, will not build in most circumstances).
Second, you need to look at the "Problems" tab to see if there are actual errors. If there is nothing there, then it did indeed compile correctly.
Now, back to the original question. Depending on the type of project you are building, this type of behavior is not that uncommon. Eclipse seems to do a poor job of indexing certain projects. When you run "make all" from the command line (which is effectively what Eclipse does during build) it is likely resolving all of your code and building it just fine.
However, Eclipse uses a different, separate tool for indexing all of your source code and resolving variable/function definitions and declarations. This is literally a case of the left hand not knowing what the right hand is doing.