Pages: [1]   Go Down
Author Topic: Eclipse C++ How do I access Libraries??  (Read 1330 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


OK,  I got the Arduino Plug-in working and I can compile stuff that uses some basic stuff.  However, I tried to port over a project that uses libraries added to the "libraries" folder.   When I try to compile, I get a unresolved inclusion error on the header for the added library. 

The library I am trying to access, I did not write.  The author of the library requested that this folder be added as a sub-folder to the libraries folder.  I did this and the code does compile fine using the Arduino IDE.  However, if fails right away when attempting to compile with Eclipse. 

The source code references the library with the line.

#include <OpenSprinkler.h>

When compiling with the IDE, the console window then contains  -IH:\Arduino\arduino-0022\libraries\OpenSprinkler
which lets the compiler know where to find the needed pieces.

With Eclipse, there is no inclusion of this library and thus the compile fails.

How do I tell Eclipse to look in the "libraries" tree? 

Is there an example project that demonstrates how to use library stuff from Eclipse?

Thanks.
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 58
Posts: 1736
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can find the info you are looking for at http://eclipse.baeyens.it/
More precise at http://eclipse.baeyens.it/UsethePlugin.html
Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Jantje,

Thank you for pointing out what I was missing.  After importing the library, I was able to get it to compile.  However, I did have to do one more step.  I had to include the library folders in the C++ compiler settings. 
Attached is a screen shot of my addition to my project:

Perhaps I did something wrong on the import.  (Highly likely)  Or perhaps it is a function of the project that I am attempting to port over.   The header for the Library is referenced by just  "#include <OpenSprinkler.h>"     Do I need more of a path declaration to let the indexer know the location of the header? 

Anyway, thanks again.  I have this project compiling and linking now, so the question are more about how to do it correctly, the next time I import.

--- Steve
 



* arduino1.bmp (2102.32 KB, 1010x710 - viewed 27 times.)
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 58
Posts: 1736
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Steve
As your image shows the plugin added $workspace_loc:/Sprinkler_Shedule/OpenSprinkler
So your addition was not needed.
See http://eclipse.baeyens.it/Arduino%20eclipse%20plugin%20FAQ.htm#bugs for more info on the indexer.

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I delete both on my additional include paths, then the code will not compile.  For the code to compile, the second include that I added is required.  The library author placed source code for a twi driver in a utility folder that is under the OpenSprinkler folder.  (I do not know why this was done.)  The Arduino IDE figures out that this code is in a lower folder and includes this folder level when compiling some stuff.   

Other than this lower folder, you are correct.   The code will compile everything else without the first include I added.   I mistakenly thought that it would not compile without this because if I search for unresolved headers, then OpenSprinkler appears in the unresolved list unless I add that first include.  I mention this because, while it appears in the list, it is not a real problem.  At compile time, it can resolve this header. 
Logged

Belgium
Offline Offline
Edison Member
*
Karma: 58
Posts: 1736
Arduino rocks; but with my plugin it can fly rocking the world ;-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Steve
The fact that you need the library sub folder utility in your include path is IMHO a bug in the OpenSprinkler code.
Note that the Arduino Eclipse plugin includes all the subfolders of the imported library (except for example) as code folders but only includes the top level to the include path.
IMHO this how proper encapsulation is done.
So as to me you are reporting a bug in the OpenSprinkler code and not my Arduino Eclipse plugin.

Best regards
Jantje
Logged

Do not PM me a question unless you are prepared to pay for consultancy.
Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Pages: [1]   Go Up
Jump to: